JS- Questions - INT

  1. What is hoisting in JS?
  2. Explain “THIS” keyword?
  3. What is NaN property in JS?

1)hoisting is the default behavior of moving all the declarations at the top of the scope before code execution.
2)“THIS” keyword refers to an object that is executing the current piece of code.“this” references the global object.
3)NaN stands for not a number.it represents a value that is not a number.it can be used to check whether a number entered is a valid number or not a number

1 Like
  1. What is hoisting in JS?
    In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution.

  2. Explain “THIS” keyword?
    *) “THIS” keyword refers to the current object in a method or constructor.
    *) And 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).

  3. What is NaN property in JS?
    *) In JavaScript, NaN stands for Not a Number.
    *) It represents a value that is not a valid number. It can be used to check whether a number entered is a valid number or not a number.
    Syntax:
    let a = NaN
    // OR
    let a = Number.NaN

1 Like
  1. Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution
  2. “THIS” keyword refers to an object that is executing the current piece of code.
  3. NaN stands for not a number.it represents a value that is not a number.
1 Like

“Hoisting” is a JavaScript mechanism where variables and function declarations are moved to the top of their respective scopes before the code is executed.

“This” keyword refers to an object that is executing the current piece of code.

NaN is short for “Not-a-Number”. In JavaScript, NaN is a value that is not a legal number.

1 Like