by @CodingExample

How to find length of a string in JavaScript

Home » javascript » How to find length of a string in JavaScript

To find the length of a string we need to use the string.length property in JavaScript.

Example:

const str = "ocean";

console.log(str.length); // 5

The length property returns the number of characters in a string.

length property is read-only.