javascript - console.log/console.dir showing last state of object, not current -
i want log how array/object changing new steps of loop. console.log bad. shows last state of object everywhere. example:
var = {}; console.log(a); // {bob1: 0, bob2: 0} a.bob1 = 0; console.log(a); // {bob1: 0, bob2: 0} a.bob2 = 0; console.log(a); // {bob1: 0, bob2: 0} i found there, on so, command: console.dir. working in same example. shows states of object correcly.
look example. command works perfect: http://jsfiddle.net/rlzvv/
now, code pls. output in console. http://jsfiddle.net/3bds7/4/
this astar algorithm. take on part (neighbor 3 loop <--- neighbor 3 start ---> code situated here <--- neighbor 3 stop -->) in console. lanes, output console 105-113:
new openset length: 2 openset after adding new vertex **shows 1 element, length 2** it shows length 2, shows 1 element. but! seems me algo working correctly (it popping element, hidden on step after). why bug appears? did did wrong? seems me, everywhere last state of array shown, not current:( me please.
that's known issue -- sounds running under chrome.
the easiest work-around json encode value log in.
console.log(json.stringify(a));
Comments
Post a Comment