Re:Deep Cloning Objects in JavaScript, the Modern Way
by baq on Friday December 22, 2023 @03:10AM
(#38732076)
Would it be shorter if it didn’t, though?
Re:Deep Cloning Objects in JavaScript, the Modern Way
by addandsubtract on Friday December 22, 2023 @05:58AM
(#38733011)
The expectation is that you import the whole library and not just one function. At which point, lodash is smaller than if each function was implemented separately.
Re:Deep Cloning Objects in JavaScript, the Modern Way
by qayxc on Friday December 22, 2023 @06:05AM
(#38733049)
Glimpsing at the source code - yes, definitely.
For example, the code imports "copyArray", a 9LoC function that does exactly the same as the built-in Array.slice() would do.
Same goes for other imported helpers like "arrayEach", which could be replaced by the built-in Array.every().
It's basically a bunch of unnecessary polyfills for built-ins.
Re:Deep Cloning Objects in JavaScript, the Modern Way
by mishac on Monday December 25, 2023 @02:45PM
(#38765491)
Unnecessary _now_ perhaps, but not unnecessary when lodash was written. In 2009, when underscore.js came out (from which lodash was a fork) Array.every() was not something you could rely on. Chrome just came out a year earlier (and didn't support Array.every until version 4) and half the world was on IE 6-7-8
https://github.com/lodash/lodash/blob/main/src/.internal/bas...