Skip to content Skip to sidebar Skip to footer

Js Object - Getting The Value

I have some JSON data - on doing console.log(json.children[0]) I'm returned: Now I'm trying to obtain the item value so I can update it. I'm trying to get the value console.log(js

Solution 1:

I can't help but notice the fact that the initial log:

Object {name: "Chocolate", children: Array[2]}

... is completely different to the expanded values shown.

It is worth noting the i mark in the console.

Object value at left was snapshotted when logged, value below was evaluated just now.

This suggests that when you actually call console.log(json.children[0]), it only has the two properties name and children. The other properties, including dx, dy and the sought value, aren't added until later in the code.

To get these values, you will have to attempt accessing them after the code that generates them runs. Of course without seeing more details on your code it's impossible to say when/where that should be, but this is what I have for you with what you've provided.

Post a Comment for "Js Object - Getting The Value"