Nate Woods

Nate Woods

Javascript Array Random

2012-12-02

Another worthy one for the notebooks, the random entry of an array!

Array.prototype.random = function() {
    return this[Math.floor(Math.random()*this.length)];
};

Useful in applications that require the gathering of a random value…duhh

×