In a conditional statement (if, else), usually, we use boolean values true and false. Ture value is known as truthy and false value is known as falsy.
anything that is not mentioned above
false, '', "", 0, -0, 0n, NaN, null, undefined
different between “==” and “===”
Ans: == is used for comparing two variables, but it ignores the datatype of the variable whereas === is used for comparing two variables, but this operator also checks datatype and compares two values.
explain this keyword
Ans:The This keyword refers to the current object in a method or constructor.
The most common use of the this keyword is to eliminate the confusion between class attributes and parameters with the same name (because a class attribute is shadowed by a method or constructor parameter).
There are three types of scope: global scope, function scope and block scope
Scopes make possible to have variables with the same name without colliding with each other
Variables and objects in inner scopes are not accessible from outer scopes
Scope chain consists of the variables and objects referenceable by the execution context
6.What are the differences between null and undefined?
Ans: null is an assigned value. It means nothing. undefined means a variable has been declared but not defined yet.
7.What is event bubble? What are the benefits of event delegate?
Ans: 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 of the target element in the same nesting hierarchy till it reaches the outermost DOM element or document objec
Benefits: Simplifies initialization and saves memory: no need to add many handlers. Less code: when adding or removing elements, no need to add/remove handlers. DOM modifications: we can mass add/remove elements with innerHTML and the like.
8.What are the differences between var, let and const
Ans: var declarations are globally scoped or function scoped while let and const are block scoped. var variables can be updated and re-declared within its scope; let variables can be updated but not re-declared; const variables can neither be updated nor re-declared.
9.What are the differences between normal function and arrow function?
Ans: Regular functions created using function declarations or expressions are constructible and callable. Since regular functions are constructible, they can be called using the new keyword. However, the arrow functions are only callable and not constructible, i.e arrow functions can never be used as constructor functions.
10.What are the usages of map, forEach, filter and find?
.forEach(), is used to execute the same code on every element in an array but does not change the array and it returns undefined.
.map() executes the same code on every element in an array and returns a new array with the updated elements.
.filter() checks every element in an array to see if it meets a certain criteria and returns a new array with the elements that return truthy for the criteria.