I\'m fairly new to JS, and realize length is considered a property. But I received a comment to not use str.length in a loop:
for (i=0; i
Length is an instance property and it's constant time
It must be implement a string with a given length that is represented as a contiguous, zero-terminated array of jschars. It does this by explicitly storing a length and a pointer to the zero-terminated array
Explicitly stored is the indicator here that it's constant time.
Read How Strings Are Implemented In SpiderMonkey for more info on how Firefox implements strings.