About order of execution in JavaScript | Sololearn: Learn to code for FREE!


About order of execution in JavaScript

https://code.sololearn.com/WRM3cmHYuoC5/?ref=app Hi everybody, In my code I used setInterval and within the function fusionate , but I declared fusionate function only After calling setInterval ( I Saw this order in the lesson). is Javascript Reading code from top to bottom or what's the reason that it works I want to understand thx.

11/24/2019 4:01:03 PM


2 Answers

New Answer


because of hoisting in pre-ES6 syntax. it is like var fusionate; // declare first code snippets such as setInterval fusionate = function() {...} // initiations this can cause bugs which are hard to debug, so in ES6 we have const keyword which cannot be hoisted https://code.sololearn.com/W7Qp4YH4XHjJ/?ref=app https://code.sololearn.com/WldMKAVDQWPQ/?ref=app


Thank you ! I'm going to Learn ES6 syntax.