loading...

re: Hoist Your Vars! (Variable Hoisting in JavaScript) VIEW POST

FULL DISCUSSION
 

While it is important to understand hoisting in JavaScript, it is also a bad practice to use it in general. I suggest that you treat JavaScript just like any other programming language and don't use hoisting.

I have a template that I follow for any script that write:
// Declare variables:

// Declare functions:

// Start of coding:

Having those three sections makes it much easier for me to keep track of what is in my script.

 

That is excellent advice and very true!

Code of Conduct Report abuse