Q. Which keyword prevents object modification?

  • (A) const
  • (B) Object.seal()
  • (C) Object.freeze()
  • (D) Object.prevent()
πŸ’¬ Discuss
βœ… Correct Answer: (C) Object.freeze()
Explanation: Object.freeze() prevents adding, removing, or modifying properties.

Q. What is the result?

Code:
let a = [1,2,3];
a.length = 0;
console.log(a);
  • (A) []
  • (B) [1,2,3]
  • (C) undefined
  • (D) null
πŸ’¬ Discuss
βœ… Correct Answer: (A) []
Explanation: Setting length = 0 clears the array.

Q. Which keyword is used to handle errors?

  • (A) handle
  • (B) try
  • (C) check
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) try
Explanation: The try...catch statement is used to handle errors.

Q. What is the output?

Code:
let x = [1,2,3];
console.log(x instanceof Array);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) SyntaxError
πŸ’¬ Discuss
βœ… Correct Answer: (A) true
Explanation: Array is the constructor for arrays, so instanceof returns true.

Q. What does the spread operator (...) do?

  • (A) Deletes properties
  • (B) Merges arrays or objects
  • (C) Freezes variables
  • (D) Compiles code
πŸ’¬ Discuss
βœ… Correct Answer: (B) Merges arrays or objects
Explanation: Spread syntax expands elements of iterable objects like arrays or objects.

Q. What will this output?

Code:
let name = 'John';
console.log(`Hello ${name}`);
  • (A) Hello ${name}
  • (B) Hello name
  • (C) Hello John
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (C) Hello John
Explanation: Template literals use ${} to interpolate variables.

Q. Which object method is used to get object keys?

  • (A) Object.getKeys()
  • (B) Object.keys()
  • (C) Object.values()
  • (D) Object.entries()
πŸ’¬ Discuss
βœ… Correct Answer: (B) Object.keys()
Explanation: Object.keys(obj) returns an array of a given object's keys.