Here you can find the source of peek()
Array.prototype.peek = function() { // Return a random object from an array. var index = Math.floor(Math.random() * this.length); return this[index]; };
Array.prototype.peek = function () { return this[this.length - 1]; };
Array.prototype.peek = function(){ if (this.length > 0){ return this[this.length - 1]; } else { return null;
Array.prototype.peek = function(index) { if(!index) index = 0; return this[this.length - index - 1];
Array.prototype._peek = function(){ if(this.length > 0) return this[this.length - 1]; return null; };