Q. What is the output?

Code:
console.log('5' === 5);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) false
Explanation: Triple equals (===) checks both value and type; string !== number.

Q. Which method is used to add elements at the beginning of an array?

  • (A) push()
  • (B) unshift()
  • (C) shift()
  • (D) concat()
πŸ’¬ Discuss
βœ… Correct Answer: (B) unshift()
Explanation: unshift() adds elements to the beginning of an array.

Q. What will the following return?

Code:
console.log(typeof null);
  • (A) null
  • (B) object
  • (C) undefined
  • (D) function
πŸ’¬ Discuss
βœ… Correct Answer: (B) object
Explanation: typeof null returns 'object' (a long-standing bug in JS).

Q. Which of these is not a primitive data type?

  • (A) String
  • (B) Number
  • (C) Boolean
  • (D) Object
πŸ’¬ Discuss
βœ… Correct Answer: (D) Object
Explanation: Object is not a primitive; it's a complex data type.

Q. What is the result?

Code:
console.log(0 === -0);
  • (A) true
  • (B) false
  • (C) TypeError
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) true
Explanation: 0 and -0 are considered equal in strict comparison.

Q. What is returned by JSON.parse('true')?

  • (A) true
  • (B) 'true'
  • (C) SyntaxError
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) true
Explanation: JSON.parse can parse valid JSON values, including booleans.

Q. What will be the output?

Code:
console.log(!!0);
  • (A) true
  • (B) false
  • (C) 0
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (B) false
Explanation: 0 is falsy, so !!0 results in false.

Q. Which function executes a function after a specified time?

  • (A) setInterval()
  • (B) clearTimeout()
  • (C) setTimeout()
  • (D) delay()
πŸ’¬ Discuss
βœ… Correct Answer: (C) setTimeout()
Explanation: setTimeout() executes a function once after the delay.

Q. What does isNaN('hello') return?

  • (A) true
  • (B) false
  • (C) NaN
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) true
Explanation: isNaN('hello') returns true because 'hello' is not a number.

Q. What is the default scope of variables declared with var?

  • (A) Block
  • (B) Function
  • (C) Global
  • (D) Module
πŸ’¬ Discuss
βœ… Correct Answer: (B) Function
Explanation: Variables declared with var are function-scoped.