How can you iterate over the properties of an object in JavaScript?

How can you iterate over the properties of an object in JavaScript?

a) for...in loop
b) Object.keys()
c) Object.entries()
d) All of the above

Answer:

d) All of the above

Explanation:

In JavaScript, you can iterate over the properties of an object using the for...in loop, Object.keys() to get an array of keys, or Object.entries() to get an array of key-value pairs. Each method provides a different way of accessing an object’s properties.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top