调用数组的toString方法,将数组变为字符串然后再用split分割还原为数组。split分割后形成的数组的每一项值为字符串,所以需要用一个map方法遍历数组将其每一项转换为数值型。
function flatten(arr) {
console.log(arr.toString());// 1,2,3,4,5,6
console.log(arr.t
调用数组的toString方法,将数组变为字符串然后再用split分割还原为数组。split分割后形成的数组的每一项值为字符串,所以需要用一个map方法遍历数组将其每一项转换为数值型。
function flatten(arr) {
console.log(arr.toString());// 1,2,3,4,5,6
console.log(arr.t
841

被折叠的 条评论
为什么被折叠?