//Make all arrays have "random" method Array.prototype.random = function() { return this[Math.floor(Math.random() * this.length)]; } //Call "random" method on an array var result = ["Hello", "world"].random();