Tag Archives: every

Eloquent Javascript ch.5 – Every And Then Some

It’s a good feeling to solve this (simple though it is) without taking a ton of time and in a way that seems fairly simple. No doubt EJ has a more elegant solution, but this is better than I have been doing. And it utilizes forEach! function every (arr, f) { var counter = 0; […]


loop through array in ES5

If you’re using an environment that supports the Array features of ES5 (directly or using a shim), you can use the new forEach function: var a = [“a”, “b”, “c”]; a.forEach(function(entry) { console.log(entry); }); forEach accepts an iterator function and, optionally, a value to use as this when calling that iterator function (not used above). The iterator function is called for each […]