Question 45Asked in DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

What is the output of the following JavaScript code? const obj = { name: "Alice" };

What is the output of the following JavaScript code? const obj = { name: "Alice" }; Object.defineProperty(obj, "age", { value: 25, writable: false }); obj.age = 30; console.log(obj.age);
  1. Aundefined
  2. BError: Cannot modify property
  3. C25
  4. D30
Show answerHide answer

Correct answer: (C) 25

Explanation

writable: false makes the age property read-only. In non-strict mode, obj.age = 30 is silently ignored, so 25 is printed. Strict mode would throw a TypeError.

From DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

This is question 45 of DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.