Reputation: 3932
Am puzzled now, like really puzzled:
got this javascript object:
{
x: 0,
y: 0,
w: 28,
h: 25,
itemid: "5FE6E709096C4B57999AABC3575AF5D8",
moveable: true,
type: "4",
fontface: "",
text: "ef00704dd40e4768a1b15c14af9b6c4b.png",
fontsize: 0,
color: "",
opacity: "",
align: 0
}
if I do console.log(theaboveobject); it outputs fine.
however if I do console.log(object.w) or console.log(object.h) I get 0 as the response 2 nights in a row this has done my head in now, whats going on, what am i missing?
console.log(artworkLine); // this outputs fine as above
console.log(artworkLine.w); // says 0
console.log(artworkLine.h); // says 0
Upvotes: 0
Views: 124
Reputation: 254886
It's just a guess but personally I've experienced the similar things several times.
It's caused by how the browsers resolve reference to an object in console. It's done in runtime in a moment of unfolding it by clicking on it. And it's likely that on that moment the object is already filled with desired data.
More details about that: http://felix-kling.de/blog/2011/08/18/inspecting-variables-in-javascript-consoles/
If you try js debugger (i.e. the one built in chrome developer tools) and put a break to the line with console.log(object);
- you would see the actual object values.
The issue can be demonstrated very easily:
unfold
label appearsObject
(assuming you use google chrome browser)foo
property specifiedNow repeat the same, but on step 4 unfold the object before unfold
label appears. And you'll see that results from step 6 are different.
Upvotes: 2