How does a JavaScript engine choose what to execute next? -
while syntactically proficient @ javascript, clueless goes on under hood. running when , how javascript engine schedules it, if indeed it's scheduled in sense of word. clueless don't know terminology should use research it.
i have assumed, hearing others parrot it, javascript engines can run 1 thread @ time. assuming true , function running when callback occurs, happens behind scenes? running function paused , callback executed or full stack of running function unwound, code in callback run.
i clueless , shameful...
how fit in ui thread in browser, how different in node.js
sorry if question bit open ended, in end asking boils down -- should research(i.e google) learn more of this.
the function being executed finishes execution before callback run. can implemented in different ways different engines.
node not different , engine responsible executing javascript code shared browsers.
since can't run 2 or more functions @ same time, , 1 function needs finish execution before other gets executed, javascript said single threaded.
web workers run on separate environment, execution not dependent on code running in page or other web workers.
Comments
Post a Comment