DEV Community

loading...

Discussion on: Is it possible to nest an array in a JavaScript object?

Collapse
1e4_ profile image
Ian • Edited

Formatting requires 3 backticks (`) not apostrophe (') fyi.

And that code won't work as you are missing some commands, each item in an object must be separated by a comma, also there is no =, you use a colon (:)


var yes = {
name: "Morris",
age: 21,
no: [22, 11, 1998]
};

Thread Thread
morrisjohn profile image
Morris John Author

Thanks. I can't believe the difference between = & : almost made me pull my entire hair out.

I saw mistake was declaring the array within the object with an equal sign (=) instead of a colon(:).

Thanks man