JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow String Right Arrow length

length  String  instance property

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