Actually, I was referring to the newer .entries methods. You know, Array.prototype.entries, Set.prototype.entries, Map.prototype.entries etc. They all return iterators and will not be slow.
Meanwhile the old and outdated Object.entries goes over the entire collection to build and return the array, which will then be iterated over by the user again. A truly unfortunate state. But hey, at least they are on the right path on the modern .entries impls!
Since we're on the topic, here's an efficient Object.entries impl instead-
Actually, I was referring to the newer
.entries
methods. You know,Array.prototype.entries
,Set.prototype.entries
,Map.prototype.entries
etc. They all return iterators and will not be slow.Meanwhile the old and outdated
Object.entries
goes over the entire collection to build and return the array, which will then be iterated over by the user again. A truly unfortunate state. But hey, at least they are on the right path on the modern.entries
impls!Since we're on the topic, here's an efficient
Object.entries
impl instead-playground
yes i thought you were talking about
Object.entries