the custom code is basically what happens in lodash already - perhaps it's faster because lodash each has overhead deciding if something is an array or object
Comparing performance of: lodash.forEach vs custom foreach
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory