We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map() 方法创建一个新数组,其结果是该数组中的每个元素是调用一次提供的函数后的返回值。 map方法接收两个参数;
Array.prototype.map2 = function(fn, target){ var result = new Array(); var len = this.length; for(var i=0;i<len;i++){ result.push(fn.call(target, this[i], i, this)); } return result; }
按照源码实现的比较复杂的可以看这个 手写数组的 map 方法
The text was updated successfully, but these errors were encountered:
No branches or pull requests
map
生成新数组元素的函数
然后callback又接收3个可选参数,分别是
callback 数组中正在处理的当前元素。
数组中正在处理的当前元素的索引。
map 方法调用的数组
执行 callback 函数时值被用作this
简单实现
按照源码实现的比较复杂的可以看这个 手写数组的 map 方法
The text was updated successfully, but these errors were encountered: