In JavaScript the Length method is used to get the amount of characters in text. JavaScript length does not have any input parameters and the method is applied to JavaScript variable. The syntax of JavaScript String Length is:
<string_variable>.length;
In this JavaScript Tutorial example we will declare string variable named my_text and we are assigning to it value “JavaScript Online Course“. The all string contains 24 letters and the JavaScript Length returns the same number, see the example below.
<html> <body> <h2>My JavaScript String Length Example</h2> <script type="text/javascript"> var my_text = "JavaScript Online Course"; document.write("<p>The length is "+my_text.length+"</p>"); </script> </body> </html>