/ Published in: JavaScript
I should've wrote this function a LONGGG time ago.
foreach($myArray, function($k, $v){ console.log($k + " :: " + $v); });
Expand |
Embed | Plain Text
function foreach($haystack, $callback){ for(var i in $haystack){ if(typeof($haystack[i]) != 'function'){ $callback(i, $haystack[i]); }; }; };
Comments
Subscribe to comments
You need to login to post a comment.

What about scoping? Your code doesn't consider this!
what ABOUT scoping?