flatMap()方法對原數(shù)組的每個成員執(zhí)行一個函數(shù),相當(dāng)于執(zhí)行Array.prototype.map(),然后對返回值組成的數(shù)組執(zhí)行flat()方法。該方法返回一個新數(shù)組,不改變原數(shù)組。 1 2 3 // 相當(dāng)于 [[2, 4], [3, 6], [4, 8]].flat() [2, 3, 4].flatMap((x) => [x, x * 2]) // [2, 4, 3, 6, 4...
www.dbjr.com.cn/article/1849...htm 2025-5-28