JavaScript String length Property

JavaScript String length Property

Summary: In this tutorial you’ll learn how to use the .length property in JavaScript.


Definition and Usage

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

The length of an empty string is 0.

Remember: Strings can be empty, a space or anything you can type on your keyboard.

Example

var firstName = "Ada";
var myData = firstName.length;
console.log(myData);
// returns 3 cause the world Ada has 3 letters/strings in it

Leave a Reply

Your email address will not be published. Required fields are marked *