Have you ever seen some code like the snippet below in Javascript and thought, WTF? Look at line 2, then look at line 8.

hoisting

The above snippet is Hoisting in action.

Hoisting is a Javascript behavior that can be easily overlooked or even unknown to developers. This tutorial will walk you through the basics of hoisting, why it’s important and some best practices.