1. What is a callback function?
A callback function is a function passed into another function as an argument. This function is invoked inside the outer function to complete an action. Let’s take a simple example of how to use callback function
2. Why do we need callbacks?
3. What is a callback hell?
Callback Hell is an anti-pattern with multiple nested callbacks which makes code hard to read and debug when dealing with asynchronous logic. The callback hell looks like below,
4. What is the typeof operator?
5. What is undefined property?
The undefined property indicates that a variable has not been assigned a value, or not declared at all. The type of undefined value is undefined too.
Any variable can be emptied by setting the value to undefined.
6. What is null value?
7. What is the difference between null and undefined?
- It is an assignment value which indicates that the variable points to no object.
- Type of null is object.
- The null value is a primitive value that represents the null, empty, or non-existent reference.
- Indicates the absence of a value for a variable
- Converted to zero (0) while performing primitive operations
- It is not an assignment value where a variable has been declared but has not yet been assigned a value.
- Type of undefined is undefined
- The undefined value is a primitive value used when a variable has not been assigned a value
- Indicates absence of variable itself
- Converted to NaN while performing primitive operations
8. What is isNaN?
The isNaN() function is used to determine whether a value is an illegal number (Not-a-Number) or not. i.e, This function returns true if the value equates to NaN. Otherwise, it returns false.
9. What are global variables?
Global variables are those that are available throughout the length of the code without any scope. The var keyword is used to declare a local variable but if you omit it then it will become global variable
10. What is NaN property?
The NaN property is a global property that represents “Not-a-Number” value. i.e, It indicates that a value is not a legal number. It is very rare to use NaN in a program, but it can be used as a return value for few cases
11. What is event bubbling?
Event bubbling is a type of event propagation where the event first triggers on the innermost target element, and then successively triggers on the ancestors (parents) of the target element in the same nesting hierarchy till it reaches the outermost DOM elemen.
12. What is BOM?