DEV Community

Discussion on: Why to use Maps over Objects in JS ?

Collapse
 
darrylnoakes profile image
Darryl Noakes

You can iterate over the keys of an object using for ... in. Same as you can ierate over the indices (i.e. keys) of an array.

Collapse
 
faisalpathan profile image
faisal khan

Thanks for commenting, i agree, but i don't prefer using for ... in, since i have to also have a check in place using .hasOwnProperty to find only the properties and methods you assigned to the object.

Some comments have been hidden by the post's author - find out more