function declaration wins or variable declaration in JavaScript Hoisting

If you have a variable and a function declared with the same name, then which has a precedence over each other in the hoisting ? This video explains that. In JavaScript function and variable declarations are hoisted at the top of the execution context. You need to remember these three rules for on the same. … Continue reading function declaration wins or variable declaration in JavaScript Hoisting

Simplifying function hoisting in JavaScript

To understand function hoisting, let us start by considering the code listed below:In any other programming language, the output here would be a reference error. However, in JavaScript you will get undefined as the output. Why? Because JavaScript hoists variables at the top of the execution context. An execution context could be the function in … Continue reading Simplifying function hoisting in JavaScript

Variable Scoping and Hoisting in JavaScript

Variable Scoping in JavaScript is quite different than other programming languages like C. In this post we will learn variable scoping in JavaScript. Simply putting, Scope of a JavaScript variable is within region of the program it is defined. So a variable defined inside function will have scope inside that function. Consider following code snippet, … Continue reading Variable Scoping and Hoisting in JavaScript