javascript - Can a variable change value during single function call (from the outside?) -
i have been meaning read entire ecma5-6 spec, cough, maybe y'all can help me instead!
can variable changed "the outside" on course of study of execution of single phone call in javascript?
pseudo-javascript example:
window.foo = true; startsomeloopmutatingfoo(); function f() { var = window.foo; // insert long, blocking work here, none of mutates window.foo var b = window.foo; // 1 time again if (a != b) { totalmindexplosion() } }
will mind blown? totalmindexplosion() called under conceivable circumstance?
here's js fiddle facilitate mind fracking: http://jsfiddle.net/mf3rc/
i'm looking resources larn when asynchronous methods executed, direct answers, or questions of clarity.
thanks so!
no, totalmindexplosion() not called.
when executed, code in closure (function) blocks process, there no chance execute other code.
example:
function(){ var = 1; window.settimeout(function(){console.log(a);}, 0); = 2; }()
this log 2 instead of 1, timeout 0 second. console.log function called after total function executed, time, variable 'a' has been set 2.
javascript
No comments:
Post a Comment