Quantcast
Viewing all articles
Browse latest Browse all 10

How To Use String Length In JavaScript

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>

Image may be NSFW.
Clik here to view.
online tech support computer help computer technician computer problems javascript classes javascript string length javascript length in javascript string length in javascript courses online javascript online course

You can try this example on this link.


Viewing all articles
Browse latest Browse all 10

Trending Articles