Is that an Array ? 14. Building an Adress book JS


Just a simple question : is that code an array ? I thought it was an object ?

var bob = {
firstName: “Bob”,
lastName: “Jones”,
phoneNumber: “(650) 777-777”,
email: ""
You have an array when you have brackets [ ] , haven’t you ? Am I wrong ?
thanks for a answer .
Here is the link


this one of the confusing things of javascript:

objects == associative array

they are the same, which is why we are allowed to both:

// object notation


// associative array notation


Extending what @stetim94 explained to you, languages have different data types. Some combine things together such as number in JavaScript, where other languages would break it out into separate data types such as int, float, double, etc.

Arrays are object data types in JavaScript. Want to see that for yourself? Put this into your code and it’ll display the data type for you.

console.log(typeof bob); //-> object

Technically then bob is an “object” data type. Right? We can also express it as an associative array, meaning that we have a key/value pair relationship.

As @stetim94 said, it is confusing. Absolutely. When we wrap up other representations into one data type, it can be confusing when we know about arrays as defined in computer science.

But you can think of an object in JavaScript as a collection. Therefore, it can be an array or an object with properties and functionality.

You can learn more here on MDN:


Thanks a lot for your explanation Stetim !


Great Tonya ! typeof to check what is the code’s nature , that’s great ! thanks


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.