无意中看到一道题:找到每个子数组中的最大值生成一个新的数组
let arr = [
[55, 10, 91],
[32, 43, 50],
[22, 11, 82],
]
let res = foo(arr) // res === [91, 50, 82]
这道题很简单有多种的写法,下面这种比较奇葩
function foo(arr) {
return arr.map(Function.prototype.apply.bind(Math.max, null))
}
思考一下:1、这里的 null 的作用 2、可不可以用 call