3 ms·
The static methods take probably-not-arrays and return arrays. An instance method takes an existing array (`this`) and returns a modified array. Of course, yo
by bsimpson 8y ago
The static methods take probably-not-arrays and return arrays. An instance method takes an existing array (`this`) and returns a modified array.
Of course, you could implement a static flatten, but it goes against the grain of all the other instance methods (map, reduce, filter, etc.). Considering how often they are chained together, it would be especially weird.
- pg_bot 8y agoIf the pipeline operator gets accepted into JS[0], I think we should go in the direction of copying those as static methods. An example would look like: [1,2,[3,4,5]] |> Array.flatten() |> Array.filter((x) => x % 2 === 0) |> Array.map((x) => x * 2) |> Array.reduce((acc, x) => acc + x) [0]: https://github.com/tc39/proposal-pipeline-operator https://github.com/tc39/proposal-pipeline-operator