Returns the codepoint length of a String object.
Caution – JavaScript strings are immutable, so the length of a string cannot be modified.
SyntaxstrVariable.length
"String Literal".length
Examples
The following code shows how to use length. JavaScript strings are immutable and cannot be modified in place. However, you can write the reversed string to an array and then call join with the empty character, which produces a string with no separator characters.
var str = "every good boy does fine";
var start = 0;
var end = str.length - 1;
var tmp = "";
var arr = new Array(end);
while (end >= 0) {
arr[start++] = str.charAt(end--);
}
var str2 = arr.join('');
document.write(str2);
Remarks
The length property contains an integer that indicates the number of characters in the String object. The last character in the String object has an index of i length - 1.
Usage Use this property to get the codepoint length of a String object.
Notes
Microsoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4