【发布时间】:2020-12-18 03:49:54
【问题描述】:
如果我这样写,我想知道为什么 arry.find() 会起作用:
const tour = tours.find(el => el.id === id);
但如果我这样写箭头函数:
const tour = tours.find((el) => {el.id === id});
有人能解释一下吗?在这两种情况下,我都会给出一个函数作为参数。
【问题讨论】:
-
因为你使用
{}的时候没有返回。
标签: javascript