不定期更新我是怎么变成憨憨的?

119 阅读1分钟

1、当箭头函数遇到{}操作符的时候,会执行{}操作符里面的语句,忽略掉前面默认的return

const arr = new Array(10).fill().map((item,index)=>{return {num: index+1}})
console.log(arr);

此时return不能省略,否则没有返回值,这个坑踩了好多遍(灬ꈍ ꈍ灬)