Created
May 18, 2013 10:54
-
-
Save nmoliveira/5604042 to your computer and use it in GitHub Desktop.
A javascript ForEach implementation
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
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