4 ms·
The problem (as I see it anyway) is that function scoping + hoisting is weird and can cause some unexpected bugs.
by kec 8y ago
The problem (as I see it anyway) is that function scoping + hoisting is weird and can cause some unexpected bugs.
- tomxor 8y agoOnce you learn that fact, and then avoid ever using function name() {} definitions, you will never have the problem of confusing hoisting actually happen to you... Yes var had it's own set of problems (which you could argue make the alternative of assigning functions to variables bad) causing unexpected bugs but those have in turn been solved very well by const and let... and just like function names, there is also no reason to use var now.