javascript - Firefox web console reflects future changes to array -
i'm using firefox's web console (ff v22). using console.info(), future changes array reflected. bug web console? or javascript on ff behave this?
for example:
var myarr = [1]; console.info(myarr) // on firefox [1,2] - not expected myarr.push(2); console.info(myarr) // on firefox [1,2] - expected
ie on other hand behave expected.
var myarr = [1]; console.info(myarr) // on ie: 1 myarr.push(2); console.info(myarr) // on ie: 1,2
this happens because console.info
call asynchronous. may not finish before lines after have completed , dealing array passed reference, console.info
call received pointer array (which seems have been updated before log made) rather value @ time console.info
called.
Comments
Post a Comment