Chapter 4. Objects
In this chapter, you will learn:
- How to create and use objects
- What are the constructor functions
From arrays to objects
As you already know from Chapter 2, Primitive Data Types, Arrays, Loops, and Conditions, an array is just a list of values. Each value has an index (a numeric key) that starts from zero and increments by one for each value.
> var myarr = ['red', 'blue', 'yellow', 'purple']; > myarr; ["red", "blue", "yellow", "purple"]. > myarr; "red" > myarr; "purple"
If you put the indexes ...