Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript String - length Property


previous next AddThis Social Bookmark Button


Advertisements

Description:

This property returns the number of characters in the string.

Syntax:

string.length

Here is the detail of parameters:

  • A string

Return Value:

Returns the number of characters in the string.

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>

This will produce following result:

str.length is:14 

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements