MATTIA PIRAS
MATTIA PIRAS

Reputation: 1

Console.log not showing array content

I'm doing an exercise for my coding class that requires to modify a tree in JavaScript, I think the code is right but testing with console.log, I can't see the leaves:

{
  val: 0,
  son: [
    { val: 0, son: [Array] },
    { val: 3 },
    { val: 0, son: [Array] },
  ]
}

I need to know what's inside [Array].

Upvotes: 0

Views: 234

Answers (1)

Throvn
Throvn

Reputation: 971

I think what you are looking for is JSON.stringify().

console.log(JSON.stingify({array: ['a','b','c']}))

This turns an object into an untruncated, readable string which will then be printed onto the console.

You can read more about it and the optional parameters here.

Upvotes: 3

Related Questions