```
Array.prototype._forEach = function(fn) {
// 怎么实现一个 forEach 方法?
};
function Person(age) {
this.age = age;
[3,5,10]._forEach(function(it){
console.log(`${it} year later I'm ${this.age + it} year old`);
});
}
let mike = new Person(12);
// 3 year later I'm 15 year old
// 5 year later I'm 17 year old
// 10 year later I'm 22 year old
```
添加回答
举报
0/150
提交
取消