{}有什么不同吗?

时间:2019-03-21 10:29:50

标签: javascript ecmascript-6

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”]


唯一的区别是{}。据我所知,{}内是否只有一句话并不重要。 你们能解释一下吗?

0 个答案:

没有答案