+ 2
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.
2 Answers
+ 2
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
0
Thank you ! I'm going to Learn ES6 syntax.