11.15 Multidimensional arrays


#1


https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/3/2?curriculum_id=506324b3a7dffd00020bf661#


My code passes. My question is about my last array. I typed in Object as an element and received no error message. Why is this?


var obj1 = {
    age: 1, name: "obj"
    };
var newArray = [[1,1], [2,2,2], [obj1, "object", Object]];


#2

Why do you think it should give an error? :wink:


#3

I assumed it would log as undefined to the console.


#4

See this code more carefully:

var newArray = [[1,1], [2,2,2], [obj1, "object", Object]];

Notice that Object is highlighted differently as compared to obj1 (which is a variable). Now go ahead, open your browser console (hit F12 key), and type Object in it.

It isn't undefined :wink:


#5

Ohhhhh, it's built into javascript?

https://jsbin.com/bacewo/edit?js,console


#6

Yes :slight_smile:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object


#7

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