Share this Page URL
Help

Chapter 4. String() > Methods - Pg. 49

String() Syntax var x = stringObj.length 49 The length property of strings, simply put, is the number of characters in the string. x = "1+2" alert(x.length) // returns 3 Special characters, covered in Chapter 13, can be made of more than one character when you express them. However, as far as the string itself is concerned, they are one character each. x = "1\n2" alert(x.length) // returns 3 You cannot change the length property of a String() object. Replacing one String() object with another is the only way to change the length. Methods anchor JavaScript 1.0+, JScript 1.0+ Nav2+, IE3+ Syntax