JavaScript Code

String length in JavaScript


String length

str.length

where

  • str is a string.

length property returns the string’s length.

Example

1. In the following program, we find the length of the string value in name.

let name = "apple";
let len = name.length;
console.log(len);

Copyright @2022