This is how underscore.js implements each()