Question 52Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

Which method is used to loop through all the enumerable properties of an object in

Which method is used to loop through all the enumerable properties of an object in JavaScript?
  1. AObject.values()
  2. BforEach()
  3. Cfor...in
  4. DObject.keys()
Show answerHide answer

Correct answer: (C) for...in

Explanation

The for...in loop iterates over all enumerable property names (keys) of an object. Object.keys() and Object.values() only return arrays, and forEach is an array method.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 52 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1: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.