Nodejs Array Random random()

Here you can find the source of random()

Method Source Code

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

Related

  1. rand()
    Array.prototype.rand = function() {
      return this[Math.floor(Math.random() * this.length)];
    };
    
  2. randEl()
    Array.prototype.randEl = function () {
      return this[Math.floor(Math.random() * this.length)]
    };
    
  3. randFromArr()
    Array.prototype.randFromArr = function() {
      var a = this[Math.floor(Math.random() * this.length)]
      return a
    };
    
  4. random()
    Array.prototype.random = function() {
      return this[Math.floor(Math.random() * this.length)];
    };
    
  5. random()
    Array.prototype.random = function() {
        return this[~~(this.length * Math.random())];
    };
    function rand(n) {
        return ~~(Math.random() * n);
    
  6. random()
    Math.randomInt = function (min, max) {
        return Math.floor(Math.random() * (max - min +1)) + min
    };
    Array.prototype.random = function () {
       return this[Math.randomInt(0, this.length-1)];
    
  7. random()
    Array.prototype.random = function() {
      if (!this.length) return;
      return this[Math.floor(Math.random() * this.length)];
    };