8 For example, the code var firstName = "Matthew document.write("second letter of name is " + firstName[1]); It is also easy to confuse String and Array objects because they both have a length property. So the code var firstName = "Matthew document.write("second letter of name is " + firstName[1]); document.write("
length of 'firstName' " + firstName.length);
is valid, and we do seethe number of characters of
the String displayed However, the
similarity is because both Strings and
Arrays are objects — see later in this unit fora detailed discussion of JavaScript objects.
Share with your friends: