1. What are the differences between null and undefined?
null means empty or non-existent value which is used to indicate “no value”. Even though typeof null returns object, null is primitive type and not an object.
2. What are the differences between == and ===?
The == will not check the type of the operands whereas === checks both type and value of the operands.
Other way of saying is, == will convert the operands to same type and then do the comparison. But === does not do any conversion. It will simply return false if any of them is in different type.
3. How can you check if the given variable is array or not?
We can use Array.isArray() to determine whether the passed value is an Array or not. However it will not run on IE8 and below. To support the old versions we can use, Object.prototype.toString.call(arr) === '[object Array]';
4. What is Scope of variable? What is Global scope and Local scope?
Scope means a set of rules to the compiler to look for a variable in the program or how the parser resolves the value of a variable.
5. What is prototype in Object? And what is constructor in Object?
Every function has a prototype property whose value is an object containing a constructor property. This constructor property points to the original constructor function.
6. What is typeof operator?
It is an unary operator, means it will have only one operand. It will return the data type of the operand, like "string", "number", or "boolean". The resulting type is always string.
A social network for devs?
Level up every day