What is the difference between “==” and “===”?
The difference between these two operators may seen simple, but it’s very important to know. Both serve as comparison operators between two variable or values, the divergence lies on the datatype they compare. The “==” operator will compare both variables irrespective of datatype, while the “===” operator will first check the datatype and then compare the values.
Here’s a quick example using the operators:
The first if statement will return true, since the operator will only check for same values, meaning that numbers can be in string format. The second comparison will return false, this because the datatype comparison will cause the comparison to fail.
What are High-Order Functions?
A high-order function is a function that operates on functions, taking one or more functions as arguments and returning a new function.
not() function is a higher-order function because it takes a function argument and returns a new function.
What is Hoisting?
Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code. It allows functions to be safely used in code before they are declared. Variable and class declarations are also hoisted, so they too can be referenced before they are declared. How ever when trying to reference the a variable or class an
ReferenceErrorvalues will be outputted since the they are not initialized yet. I would recommend only using hoisting with functions to avoid these kind of errors.
What is a Closure?
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). With this you can do two things:
- Have access to the lexical environment within which the function was declared. This environment consists of any local variables that were in-scope at the time the closure was created. So even if you declared the function in a local scoped with some variables locally defined, you will still have access to them if running the function in a global scope.
What is Currying?
As you can see currying does not change functionality, it just changes the way the function is invoked!
What are Arrow Functions?
An arrow function expression is a compact alternative to a traditional function expression, but is limited and can’t be used in all situations. It is mainly used to simplify and reduce the number of lines it takes to declare a function. Some of the limitations lie on that arrow functions does not have its own binding to this, instead they use the context of their parent. They are also not suitable for using the call(), apply() and bind() methods, since they generally rely on establishing scope for functioning.
What is a Prototype?
null for its own prototype.