Contact emails
mat...@chromium.org, bme...@chromium.org
Spec
https://tc39.github.io/proposal-flatMap/
Summary
A Stage 3 proposal introduces two new array methods.
Array.prototype.flat flattens arrays recursively up to the specified depth, which defaults to 1.
// Flatten one level:
const array = [1, [2, [3]]];
array.flat();
// → [1, 2, [3]]
// Flatten recursively until the array contains no more nested arrays:
array.flat(Infinity);
// → [1, 2, 3]
The same proposal includes Array.prototype.flatMap, which is like Array.prototype.map except it flattens the result into a new array.
[2, 3, 4].flatMap((x) => [x, x * 2]);
// → [2, 4, 3, 6, 4, 8]
Interoperability and compatibility risk
The flat method was originally called flatten, which was found to be not Web-compatible when Firefox shipped it. More recently, flatten was renamed into flat in the hopes of it resolving the compatibility issue.
Firefox: Public support (they shipped the proposal in its earlier form, and will now rename)
Edge: No public signals
Safari: Public support (Safari TP currently has a flatten implementation which they’ll rename)
Is this feature fully tested?
Yes; our implementation passes our own V8 tests as well as the Test262 tests for these two features.
Tracking bug
https://bugs.chromium.org/p/v8/issues/detail?id=7220
Link to entry on the Chrome Platform Status dashboard
https://www.chromestatus.com/feature/6629507075145728
Requesting approval to ship?
Yes. Note that since this is a V8/JS feature, this post is just an FYI to blink-dev — no signoff from Blink API owners is required.
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.