How to print an object in an array to console

Just a small question as how to make this work. The way I’m trying to do this is by using console.log within a for loop of the array in question like so:


In the console it reads out [Object object] plus any other string or value I attach to the log.

you could just do console.log(JSON.stringify(array))

Returns error: Converting circular structure to JSON

It seems that you have objects inside the array that are referring themselves.

Try just console.log(array) and see if you can expand the row in the console.

Otherwise, set a breakpoint and inspect the value in debug mode.

I’ve tried this, and it says the same thing only five times per line instead of once per line


Should work. Your array is probably like this:

    "[Object object]",
    "[Object object]",
    "[Object object]",
    "[Object object]",
    "[Object object]"

That’s pretty much exactly what its doing, I’m trying to get it to print out the names of the objects though.

Here is a simple demo.


How do you initialize your array ? And how do you print your array ?

This is how I print the array.

I initialize the array like so:

dice ='Dice');

In the case of the actual script, array is replaced with dice, and my end goal is to get the console to print out Dice1 has stopped, Dice2 has stopped, etc. when the check confirms they have stopped moving. Or even if it could just say the objects position in the array.