How to get the length of a string in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To get the length of a string in JavaScript, use the length property. The length property returns the number of characters in a string.

Example

You can try to run the following code to learn how to get the length of a string

Live Demo

<html>
   <head>
      <title>JavaScript String length Property</title>
   </head>
 
   <body>
      <script>
         var str = new String( "Tutorialspoint Tutorials" );
         document.write("Length of string:" + str.length);
      </script>
   </body>
</html>
raja
Published on 18-Jan-2018 17:39:19
Advertisements