Standard built-ins

String length

Try the free JavaScript compiler

The length property of a string value counts its UTF-16 code units. Surrogate pairs occupy two units and grapheme clusters may span more. The property does not count UTF-8 bytes or visible characters.

Formal Syntax & Structure

javascript syntaxjavascript
text.length

Return Value

number

Nonnegative number of UTF-16 code units.

Working Example

Example Snippetjavascript
console.log("A😀".length);
JavaScript Reference