Array.pluck #1064

merged 1 commit into from Nov 4, 2011

2 participants


Good complement to Array.invoke, this method is in Prototype and ExtJS (off the top of my head; there could be others).

Thomas Allen Array.pluck 6d78fa9
MooTools member

Sure whynot.

@cpojer cpojer merged commit df02433 into mootools:master Nov 4, 2011
MooTools member

Very nice!

Alternative implementation without relying on .map and function calls, which should be a bit faster:


    pluck: function(property){
        var length = this.length >>> 0, results = new Array(length);
        for (var i = 0; i < length; i++){
            if (i in this) results[i] = this[i][property];
        return results;



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment