Javascript - String length Property

The length property returns the length of a string (number of characters).

Description

The length property returns the length of a string (number of characters).

The length of an empty string is 0.

Syntax

string.length

Return

The length of a string

Example

Return the number of characters in a string:

Demo

//return the number of characters in the string "Hello World!".
var str = "Hello World!";
var n = str.length;
console.log(n);/*  www  . ja va  2s.c  o m*/

Result