*Contact [email protected] <[email protected]>, [email protected] <[email protected]> Spechttps://tc39.github.io/proposal-flatMap/ <https://tc39.github.io/proposal-flatMap/> SummaryA 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 riskThe flat method was originally called flatten, which was found to be not Web-compatible when Firefox shipped it <https://developers.google.com/web/updates/2018/03/smooshgate>. 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)- Web developers: Strongly positive <https://twitter.com/mathias/status/999101901697363969>Is this feature fully tested?Yes; our implementation passes our own V8 tests as well as the Test262 tests for these two features.Tracking bughttps://bugs.chromium.org/p/v8/issues/detail?id=7220 <https://bugs.chromium.org/p/v8/issues/detail?id=7220> Link to entry on the Chrome Platform Status dashboardhttps://www.chromestatus.com/feature/6629507075145728 <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 [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
