3 ms·
Hoisting is great thing, it is really helpful to improve readability when doing asynchronous function calls. function a(){ setTimeout(b, 1000); }
by gildas 12y ago
Hoisting is great thing, it is really helpful to improve readability when doing asynchronous function calls.
function a(){
setTimeout(b, 1000);
}
function b() {
setTimeout(c, 1000);
}
function c() {
}
- kaoD 12y agoIf I'm not mistaken that's not hoisting, since that code will work as long as a() is called after b is declared regardless of the hoisting. Keep in mind b is only accessed when a() is actually executed, not when it's declared! Hoisting works like this: a(); function a() { console.log("FOO"); } Which might or might not be more readable, depending on your tastes.
- deleted 12y ago[deleted]
- gildas 12y agoYou're right, my example was not very good indeed.