Skip to content
Advertisement

Can I create an object without a name in JS?

I have a structure that looks like this:

JavaScript

I can iterate over them in a loop like this:

JavaScript

Do I assume correctly that in the cards array I have a couple of objects without names?

If so, how can I push more objects like that to the cards array without giving them names? I want to create those objects in a for loop.

Advertisement

Answer

I’m not sure what you mean by names, but you can push more objects into the array as such:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement