Advanced-Frontend / Daily-Interview-Question

我是依扬(木易杨),公众号「高级前端进阶」作者,每天搞定一道前端大厂面试题,祝大家天天进步,一年后会看到不一样的自己。
https://muyiy.cn/question/
27.43k stars 3.29k forks source link

commit #563

Open jobs2817 opened 2 years ago

jobs2817 commented 2 years ago

Array.prototype.map = function(fun, ctx) { if (Object.prototype.toString.call(fun) !== '[object Function]') { throw new Error(${fun} is not function) } const arr = [] for (let i= 0; i<this.length; i++) { arr.push(fun.call(ctx, this[i], i)) } return arr }