How can you iterate over the properties of an object in JavaScript?
a)
for...in
loopb)
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.