var
let
const
==
only checks for the value. performs coercion before checking.
===
checks for value + type. no coercion.
what are the most frequently used array methods in JS?
map, filter, find, reduce, forEach
The map() array method
The filter() array method
the forEach() array method
What are the two ways to make a function in JS?
What are the 3 types of scope?
What is a closure?
An inner function returned by an outer function that references a variable defined in the outer function, ie. a “closed-over-variable”
Even when functions are returned (in the above case y) they still remember their lexical scope (where it came from)
So, when we finally invoke z, y is invoked. Now, y has to log a so it first tries to find 🔍 it in the local memory but it’s not there. It goes to its parent function. It finds a there.
What is a lexical environment? How is it related to a closure?
It is essentially the surrounding state – the local memory along with the lexical environment of its parent.
What are the advantages of closures in JavaScript?
What are the disadvantages of closures in JavaScript?
Overconsumption of memory or memory leaks can happen.
For example, the closed-over-variable will not be garbage collected. This is because, even if the outer function has run, the returned inner function still has a reference to the closed-over-variable.
Note: Garbage collection basically removes unused variables from the memory automatically.
What is hoisting in JavaScript?
This is JavaScript’s default behavior of moving declarations to the top of the program.
How is var hoisted in JS?
var declaration is hoisted up and initialized with undefined.
How are let and const hoisted in JS?
let and const declarations are hoisted up but not initialized.
how are function definitions hoisted in JS?
function definitions are also hoisted up and stored as they are.
What is Implicit Binding?
When the value of this depends on how and where we are doing the calling.
What is Explicit Binding?
Explicit binding is when you force a function to use a certain object as its this.
call()
apply()
bind()