In terms of variables and constants, the keyword
var is hoisted. And
const do not allow hoisting.
In Hoisting, the variable declaration is only accessible to the immediate scope. If a variable is used with the
const the keyword that variable is not hoisted.
A Function can be called before declaring it. However, when a function is used as an expression, an error occurs because only declarations are hoisted.
Generally, Hoisting is not performed in programming languages like C, C++, and Java. Hoisting can cause undesirable outcomes in your program. It is best to declare variables and functions first before using them and avoid hoisting.
In the case of variables, it is better to use
Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said Learning is Journey and Journey never ends. Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitant that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember Every Master was Once a Beginner. Work hard and Give your best.
Jai Hind, Vande Mataram 🇮🇳