mdn / sprints

Archived: MDN Web Docs issues are tracked in the content repository.
https://github.com/mdn/content
Creative Commons Zero v1.0 Universal
150 stars 142 forks source link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map #3964

Closed tlebon closed 3 years ago

tlebon commented 3 years ago

Request type

Details

The 'iteration' row of the table comparing objects and maps has an issue for objects. It reads:

Iterating over an Object requires obtaining its keys in some fashion and iterating over them.

not necessarily true. In the same way maps are iterable with a for..of loop, so are objects with the for ...in, as of ES6. source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

hamishwillee commented 3 years ago

Thanks! I updated the section as shown so that it makes clear the limitation is that you can't just plug in any object into for...of because it isn't an iterable. See

image

The original note was pretty much "you can do this if you have the keys" (which is true). The new one points more at how you would actually tend to add support for iteration.

OK?

tlebon commented 3 years ago

seems nice to me.