Skip to content

Instantly share code, notes, and snippets.

@nmoliveira
Created May 18, 2013 10:54
Show Gist options
  • Save nmoliveira/5604042 to your computer and use it in GitHub Desktop.
Save nmoliveira/5604042 to your computer and use it in GitHub Desktop.
A javascript ForEach implementation
function forEach(list,callback) {
for (var n = 0; n < list.length; n++) {
callback.call(list[n]);
}
}
var myArray = ['hello','world'];
forEach(
myArray,
function(){
alert(this); // do something
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment