Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

模拟相对正确的 Array.prototype.forEach

  • Loading branch information...
commit 4dd1a1bd8ea094e2dceaf964ad3eae6a6d8f77ef 1 parent 5316d8d
@penJunTan penJunTan authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/index.js
View
4 lib/index.js
@@ -41,8 +41,8 @@ if (typeof window !== 'undefined') {
};
}
if (!Array.prototype.forEach) {
- Array.prototype.forEach = function (fn) {
- for (var i = 0; i < this.length; i++) fn(this[i], i, this);
+ Array.prototype.forEach = function (fn, scope) {
+ for (var i = 0; i < this.length; i++) fn.call(scope, this[i], i, this);
};
}
if(!String.prototype.trim){
Please sign in to comment.
Something went wrong with that request. Please try again.