What you are looking for is a lazy iteration over the properties of an object or array. This is not possible in ES5 (thus, it is not possible in many implementations such as node.js). We will get it in the end.
Memory, both for ... in
and Object.keys.forEach
, will load the entire set of attributes into memory. How much actual memory is used in each JS engine can vary significantly. You should always test your code in different scenarios and use several engines to determine which ones are best for your application.
source share