const fruits = ["Apples", "Oranges", "Grapes"];
const singleFruit = fruits.map(fruit => {
fruit.slice(0, -1);
});
console.log(singleFruit);
输出:(3)[undefined,undefined,undefined]
但map()中没有{},
const fruits = ["Apples", "Oranges", "Grapes"];
const singleFruit = fruits.map(fruit => fruit.slice(0, -1));
console.log(singleFruit);
输出:(3)[“ Apple”,“ Orange”,“ Grape”]
唯一的区别是{}。据我所知,{}内是否只有一句话并不重要。 你们能解释一下吗?