This textbook is available atAmazon.com Logo
JavaScript: The Web Warrior Series 6th Edition

JavaScript: The Web Warrior Series (6th Edition)

Book Edition6th Edition
Author(s)Vodnik
ISBN9781305078444
PublisherCengage
SubjectComputer Science
Chapter 8, Formatting Strings, Short Quiz, Exercise 1
Page 553

What string property returns the number of characters in a string?

Explanation

The length property is a property of the String class that returns the number of characters that makes up the string. If the string is empty, then the length property will return 0. It can be accessed as follows.

var str = "hello world";
var count  = str.length;

The variable str corresponds to an object of class String that contains the text "hello world" and dot (.) operator is used to access the property length. As the result of execution of the above statements, the variable count contains the value 11.

Verified Answer

length 

How would you rate this answer and explanation?
Did you like this example?
Subscribe for full access
Page 553