Q. What will be logged?

Code:
let a = 1;
let b = a++;
console.log(b);
  • (A) 2
  • (B) 1
  • (C) undefined
  • (D) NaN
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1
Explanation: Post-increment returns the value before incrementing.

Q. Which object method returns an array of a given object's property names?

  • (A) Object.keys()
  • (B) Object.names()
  • (C) Object.get()
  • (D) Object.entries()
πŸ’¬ Discuss
βœ… Correct Answer: (A) Object.keys()
Explanation: Object.keys() returns an array of keys in an object.

Q. What will be the result?

Code:
typeof function(){};
  • (A) function
  • (B) object
  • (C) undefined
  • (D) function()
πŸ’¬ Discuss
βœ… Correct Answer: (A) function
Explanation: Functions are of type 'function' in JavaScript.

Q. Which operator is used to merge two arrays?

  • (A) +
  • (B) &
  • (C) concat()
  • (D) merge()
πŸ’¬ Discuss
βœ… Correct Answer: (C) concat()
Explanation: The concat() method is used to merge arrays.

Q. What will this return?

Code:
[1, 2, 3].includes(2);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) NaN
πŸ’¬ Discuss
βœ… Correct Answer: (A) true
Explanation: includes() checks if the element is present and returns true or false.

Q. Which of the following is a falsy value?

  • (A) 0
  • (B) null
  • (C) undefined
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: 0, null, undefined, '', false, and NaN are all falsy values.

Q. What is the value of x?

Code:
let x = '5';
x = +x;
  • (A) '5'
  • (B) 5
  • (C) NaN
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (B) 5
Explanation: Unary plus converts the string to a number.

Q. What does this expression return?

Code:
Boolean('false');
  • (A) false
  • (B) true
  • (C) undefined
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) true
Explanation: Any non-empty string, including 'false', is truthy.

Q. What is a Promise in JavaScript?

  • (A) A function that never runs
  • (B) A placeholder for a future value
  • (C) A data type
  • (D) An error object
πŸ’¬ Discuss
βœ… Correct Answer: (B) A placeholder for a future value
Explanation: A Promise represents the eventual completion or failure of an async operation.

Q. Which function is used to execute a function after a delay?

  • (A) setInterval()
  • (B) setTimeout()
  • (C) delay()
  • (D) timeout()
πŸ’¬ Discuss
βœ… Correct Answer: (B) setTimeout()
Explanation: setTimeout() is used to run code after a specified delay.