January 2018
Intermediate to advanced
678 pages
20h 16m
English
There are two forms for strings—string primitives and string objects. A string primitive is simply a group of characters. String primitives are also known as string literals, and they are written with single quotes (as in ‘Carpe Diem!’) or double quotes (as in “Let’s not seize the day—let’s have a meeting instead!”). A string object wraps up a string primitive, and in doing so, it adds properties and methods. In this section, we’ll introduce one string property and several string methods.
A string object’s length property returns the number of characters in the string. Note this example, which uses the length property:
var musician = "Taylor Swift"; alert("There are " + musician.length + " characters in \"" + musician ...Read now
Unlock full access