数组find原理
let arr = [20, 40, 60];
Array.prototype.myfind = function (fn) {
for (let i = 0; i < this.length; i++) {
let flag = fn(this[i],i,this);
if (flag) {
return this[i];
}
}
};
let r = arr.find(item=>item==40);
console.log(r)
数组from 原理
let str = "hello";
Array.myfrom = function () {
let arr = [];
Array.prototype.forEach.call(arguments, function (item) {
arr.push(item);
});
return arr;****
};
let r = Array.myfrom(str)
console.log(r)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。