Created
August 6, 2015 00:20
-
-
Save goshmx/a81aeff69b4cc6e7a80b to your computer and use it in GitHub Desktop.
Recorre un array asociativo
This file contains hidden or 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
/** | |
* 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