3 ms·
Infinity was originally the default (which feels intuitive), but here's the argument for changing it [0]: "I think Array#flatten should be shallow by default b
by kevlened 7y ago
Infinity was originally the default (which feels intuitive), but here's the argument for changing it [0]:
"I think Array#flatten should be shallow by default because it makes sense to do less work by default, it aligns with existing APIs like the DOM Node#cloneNode which is shallow by default, and it would align with the existing ES3 pattern of using Array#concat for a shallow flatten. Shallow by default would also align with flatMap too."
[0] https://github.com/tc39/proposal-flatMap/issues/9 https://github.com/tc39/proposal-flatMap/issues/9
- dawhizkid 7y agoI’m trying to think of a single use case where I’d want to flatten exactly one level of an array and can’t.