Skip to content

Instantly share code, notes, and snippets.

@goshmx
Created August 6, 2015 00:20
Show Gist options
  • Save goshmx/a81aeff69b4cc6e7a80b to your computer and use it in GitHub Desktop.
Save goshmx/a81aeff69b4cc6e7a80b to your computer and use it in GitHub Desktop.
Recorre un array asociativo
/**
* Prototipo para recorrer de forma iterativa un array de arrays.
* @author @Gosh_
* @param callback function
*/
Array.prototype.IteraArrays = function (cb) {
this.forEach(function (obj, inx) {
// Si no es un array esperamos para disparar el iterador
if (obj.constructor === Array) {
obj.IteraArrays.call(obj, cb);
} else {
// Si no es un array dispara el callback
cb.apply(this, [obj, inx]);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment