String length property in JavaScript

You can get the string length in javascript by length property.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>String length property in JavaScript</title>
  <script>
    var str = "JavaScript";
    var strLength = str.length;
    document.write("Length is: ", strLength);
  </script>
</head>
<body>
</body>
</html>

Output:

Length is: 10

Leave a Reply