然后我们再打印一下 被查找的数据 memoList
console.log(memoList)
// [{id: 1, name: "1"}, {id: 2, name: "我是修改后的"}, {id: 3, name: "3"}]
// 看得没 memoList 内的数据也被修改了
这里就反应出 fine() 方法返回的结果内存指向依然是
memoList
所指向的内存地址
所有这里返回的是浅拷贝的数据
注意:
find() 对于空数组,函数是不会执行的。
注意:
find() 并没有改变数组的原始值。
浏览器支持
表格中的数字表示支持该方法的第一个浏览器版本号。
find()
注意:
IE 11 及更早版本不支持 find() 方法。
array.find(function(currentValue, index, arr),thisValue)
参数描述
function(currentValue, index,arr)
必需。数组每个元素需要执行的函数。
函数参数:
参数描述
currentValue
必需。当前元素
index
可选。当前元素的索引值
可选。当前元素所属的数组对象