Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

console.log returns [Object] when object is in multiple other objects [duplicate]

When I have a lot of objects together and I run it using nodejs in cmd It says the [Object] instead of the actual contents of the object.

here is an example from my command prompt example of problem

myObject = {
  '698045139763069009':{ users: { '560433156377804828': {name: "mark", age: "28"}},info: {} }
}
console.log(myObject);

code here ^^^

same thing happens with an array

myObject = {
  '698045139763069009':{ users: { '560433156377804828': ["mark", 28]},info: {} }
}
console.log(myObject);

example

and a screen shot ^^^

help would be appreciated! thanks

like image 679
Mikitaka Avatar asked Jan 18 '26 21:01

Mikitaka


1 Answers

Looks like your console doesn't print nested objects.

Change console.log(someObject) to console.log(JSON.stringify(someObject)).

Note that it will give error if the object is cyclic / has circular references.

like image 161
chiragrtr Avatar answered Jan 20 '26 11:01

chiragrtr