length  String  instance propertyS2C Home  « Globals « String « length

Description

Returns a positive integer holding the number of characters within the string.

Syntax

Signature Description
aString.lengthReturns a positive integer holding the number of characters within the string.

Parameters

None.

Examples

The code below a string and displays the string and length.


// Create a string with a length of 16.
var aString = new String('Learn JavaScript');
alert(aString + ' - ' + aString.length);

Press the button below to action the above code:


Related Tutorials

JavaScript Basic Tutorials - Lesson 8 - Strings

go to home page Homepage go to top of page Top