Javascript Array take(length)

Description

Javascript Array take(length)



Array.prototype.take = function (length) {
  var result = new Array();
  length = Math.min(this.length, length);
  for (var i = 0; i < length; i++)
    result.push(this[i]);//from  ww w  .j  av  a 2 s  .c o m
  return result;
};



PreviousNext

Related