Skip to content

Instantly share code, notes, and snippets.

@front-thinking
Created January 12, 2016 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save front-thinking/6294a722aee5f9dc5308 to your computer and use it in GitHub Desktop.
Save front-thinking/6294a722aee5f9dc5308 to your computer and use it in GitHub Desktop.
自己动手实现的迭代器-简易版
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