4 ms·
Iterating over an object keys, an array or a map?
by makapuf 5y ago
Iterating over an object keys, an array or a map?
- kingdomcome50 5y agoI would expect, given you have described an operation on 3 different data structures using different words, that it would also demand 3 different kinds of syntax/denotation no? Your own language requires as much. Why not JS?
- makapuf 5y agoWell in python by example you use for x in myobject to iterate and that's it, no Object.entries(myobj) vs. mymap.entries , lua is even more consistent, ..
- deleted 5y ago[deleted]
- frankenst1 5y agolet obj = {a:1}, arr = [1], map = new Map().set("a",1); // Iterating over an object keys for (let x of Object.keys(obj)) {...} // an array for (let x of arr) {...} // or a map? for (let x of map) {...}