This property returns the number of characters in a string.
Use the following syntax to find the length of a string −
string.length
Returns the number of characters in the string.
Try the following example.
<html> <head> <title>JavaScript String length Property</title> </head> <body> <script type="text/javascript"> var str = new String( "This is string" ); document.write("str.length is:" + str.length); </script> </body> </html>
str.length is:14