Closure is created when inner functions are able to access the variables of outer function. What closure does is it remembers the state of the function, even after the function as returned. If we have to create a
closure, we have to define a function inside another function and return so, that inner function will be having access to outer function variables.
Lexical environment is a reference to the outer functions scope and is part of the every function execution context.
Unlike a normal function,
closure allows the function to access the stored variables through closures copy of their references even when it is called outside the function. As every function will be having a reference to its lexical environment that's how it sees and can access variables declared outside the function. …
this keyword is referencing to. Every function receives two addition parameters excluding declared parameter:
Every function while executing has a reference to its current execution context called “
this". Here execution refers to where the function is getting called and when it will be called. There are four rules for how "this" keyword gets bind. It tells how "this" keyword will get bind for functions. Let's see what are those.
Let's take an example and see how “this” gets bind. …
In my last post, we have discussed all about scope. When we started looking in-depth we thought like how come var doesn’t through error even if its undeclared. So we are going to discuss about hoisting and what actually it is happening.
So let’s take a simple example (here compilation phase means after hoisting)
In image 1 what it happens is first it will do a run through the code and defines a and b. Meant first the compilation of variables and function expressions will happen from lines 1–6 before execution. After that we can see from image 2(compilation phase), variable declaration of a and b has moved to the top of the scope. This is called hoisting or hoisting the variables and functions to the top of the scope. …
A variable declared outside a function becomes global. All functions have access to global variables. Declarations, where they are occurred will be processed before any code execution is done and there initial value is. This is called as and we will discuss that as well.
Variables that are available only in a specific part of our code are considered to be in the local scope. …
Map uses key value pairs and keeps the original insertion order of the keys. Any value may be used as key.
Properties and Methods of Map (only Size is property)