Q. Which value is returned when a function doesn't explicitly return anything?

  • (A) null
  • (B) undefined
  • (C) false
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (B) undefined
Explanation: A function with no return returns undefined.

Q. How can you clone an object in JavaScript?

  • (A) Object.clone(obj)
  • (B) obj.copy()
  • (C) Object.assign({}, obj)
  • (D) clone(obj)
πŸ’¬ Discuss
βœ… Correct Answer: (C) Object.assign({}, obj)
Explanation: Object.assign({}, obj) creates a shallow copy of obj.

Q. What does the 'await' keyword do?

  • (A) Pauses the function until a promise settles
  • (B) Pauses script execution globally
  • (C) Rejects promises
  • (D) Creates a new thread
πŸ’¬ Discuss
βœ… Correct Answer: (A) Pauses the function until a promise settles
Explanation: await pauses an async function until the promise settles.

Q. What is the output?

Code:
console.log(3 > 2 > 1);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) NaN
πŸ’¬ Discuss
βœ… Correct Answer: (B) false
Explanation: 3 > 2 is true (1), then 1 > 1 is false.

Q. What type is returned by Array.isArray([])?

  • (A) boolean
  • (B) string
  • (C) object
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) boolean
Explanation: Array.isArray returns a boolean indicating if input is an array.

Q. Which method returns the first index of an element?

  • (A) search()
  • (B) findIndex()
  • (C) indexOf()
  • (D) find()
πŸ’¬ Discuss
βœ… Correct Answer: (C) indexOf()
Explanation: indexOf() returns the first index of a matching element.

Q. Which of the following is true about 'const'?

  • (A) Cannot be reassigned
  • (B) Cannot be mutated
  • (C) Not block-scoped
  • (D) Hoisted to top with undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) Cannot be reassigned
Explanation: const variables cannot be reassigned but can be mutated (for objects).

Q. What will this return?

Code:
console.log('10' - '4' - '3' - 2 + '5');
  • (A) 15
  • (B) 1
  • (C) 15
  • (D) 15undefined
πŸ’¬ Discuss
βœ… Correct Answer: (C) 15
Explanation: '10' - '4' - '3' - 2 = 1, then 1 + '5' = '15'.

Q. Which statement is true about let, var, and const?

  • (A) var is block scoped
  • (B) let is function scoped
  • (C) const must be initialized
  • (D) const can be reassigned
πŸ’¬ Discuss
βœ… Correct Answer: (C) const must be initialized
Explanation: const must be initialized when declared.

Q. How to convert a string to an integer in JavaScript?

  • (A) parseInt(str)
  • (B) Number(str)
  • (C) +str
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: All mentioned methods can convert string to number.