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
Test case name
Result
lodash.forEach
custom foreach
Fastest:N/A
Slowest:N/A
Latest run results:
Run details: (Test run date:
2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0