15 Why is this working?


#1

var newArray = [[{}, 2],["cat", true, 12]];

When asked to add an object to an array, I have found that by simply adding { }, curly braces to the array....it allows me to proceed. Why is that? Thanks in advance.


#2

Maybe because it works as an object in an array? It may be something like booleans, where "true" and "false" work without quotations. Have you tried putting colons or something else?

JS may just be able to hold it as an object.


#3

Yes actually, when it passed the first time. I tried entering, a boolean, number, and string in its place and I was getting the message asking me to add an object. When I place the { } back in, it worked.