The dictionary meaning of hoisting is – raise (something) by means of ropes and pulleys.
Let’s try to understand this with some examples:
Using variable before declaring
Invoking function before defining
Though, We should keep in mind that hoisting pulls only the declarations to top and not initialisations. So, the below example will always log `undefined`.
Though you get hoisting for free but the best practice says that we should always declare our variables and define our functions before using them and invoking them respectively in order to save ourselves some mess. Also, declarations first approach will make life easier during debugging.