Created
January 12, 2016 01:56
-
-
Save front-thinking/6294a722aee5f9dc5308 to your computer and use it in GitHub Desktop.
自己动手实现的迭代器-简易版
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var each = function (arr, callback){ | |
for(var i=0, l=arr.length; i<l; i++){ | |
callback.call(arr[i], i, arr[i]); | |
} | |
}; | |
each([1, 2, 3], function (i, n){ | |
console.log([i, n]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment