Nodejs Utililty Methods Array Peek

List of utility methods to do Array Peek

Description

The list of methods to do Array Peek are organized into topic(s).

Method

peek()
Array.prototype.peek = function () {
  return this[this.length - 1];
};
peek()
Array.prototype.peek = function(){
    if (this.length > 0){
        return this[this.length - 1];
    } else {
        return null;
peek()
Array.prototype.peek = function() {
    var index = Math.floor(Math.random() * this.length);
    return this[index];
};
peek(index)
Array.prototype.peek = function(index) {
   if(!index) index = 0;
   return this[this.length - index - 1];
_peek()
Array.prototype._peek = function(){
    if(this.length > 0) return this[this.length - 1];
    return null;
  };