Q1: What is means by truthy and falsy value?
Ans: In javascript, a truthy value is a value that considers true when encountered in a Boolean context. We consider the value that passes in the if block. Truthy value is true, {}, [], 42, "0", "false", new Date()
, and falsy value is false, 0, "", null, undefined, NaN
.
Q2: What is the difference between null and undefined?
Ans: Undefined variable is those that variable is declared in the program but have not been given any value. But the null value is used to represent the no value or no object. It implies that no object, null string, no valid boolean value, no number, no array object.
Q3: How you get undefined?
Ans: I think I get undefined in two ways. One is if I declared a variable but not given any value and another is I call a function that has to return nothing.
Q4: What is the meaning of == and ===?
Ans: == is slite restrict in checking two variables that are equal or not but not check their type. In ==== is restrict in checking two variables that are equal and also check their type.
Q5: What do you mean by block scope and functional scope?
Ans: A block scope is an area within if, switch conditions or for and while loops. Functional scope means the area within the function.
Q6: How you declare a private variable in JavaScript and what is encapsulation?
Ans: Private property of an object is declared using _ adding at the first position of a variable.
Ans: A group of related variables and functions seems to be a unit where the variables are called property and functions are call methods And this process is called encapsulation.
Q7: What is the meaning of this keyword in js and how you understand it?
Ans: In javascript, this refers to the object that it belongs to. In a function, this refers to the global object ( in browser this refers to window object ). In method call or property call, this refers to the left side object of .
notation.
Q8: Tell detail about the call, bind, apply?
Ans: If I want to bind an external function to an object I use the call()
method to the function. If I want to bind an external function to an object I also use apply()
method to the function. The difference between call()
and apply()
is that the second parameter of the apply()
is an array. Bind also works the same style as call()
but it returns a function.
Top comments (0)