+ 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.

24th Nov 2019, 4:01 PM
Roronoa
Roronoa - avatar
2 odpowiedzi
+ 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
24th Nov 2019, 5:32 PM
Gordon
Gordon - avatar
0
Thank you ! I'm going to Learn ES6 syntax.
24th Nov 2019, 5:56 PM
Roronoa
Roronoa - avatar