Is Chrome's JavaScript console lazy about evaluating arrays? -


i'll start code:

var s = ["hi"]; console.log(s); s[0] = "bye"; console.log(s); 

simple, right? in response this, firebug says:

["hi"] ["bye"] 

wonderful, chrome's javascript console (7.0.517.41 beta) says:

["bye"] ["bye"] 

have done wrong, or chrome's javascript console being exceptionally lazy evaluating array?

thanks comment, tec. able find existing unconfirmed webkit bug explains issue: https://bugs.webkit.org/show_bug.cgi?id=35801 (edit: fixed!)

there appears debate regarding how of bug , whether it's fixable. seem bad behavior me. troubling me because, in chrome @ least, occurs when code resides in scripts executed (before page loaded), when console open, whenever page refreshed. calling console.log when console not yet active results in reference object being queued, not output console contain. therefore, array (or object), not evaluated until console ready. case of lazy evaluation.

however, there simple way avoid in code:

var s = ["hi"]; console.log(s.tostring()); s[0] = "bye"; console.log(s.tostring()); 

by calling tostring, create representation in memory not altered following statements, console read when ready. console output different passing object directly, seems acceptable:

hi bye 

Comments

Popular posts from this blog

html - Cut text on left side inside button while centering -

What design pattern is this code in Javascript? -

java - Last square of 8x8 grid not drawn, using two nested FOR loops -