Nodejs Utililty Methods Array Take

List of utility methods to do Array Take

Description

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

Method

take(c)
Array.prototype.take = function (c) {
  return this.slice(0, c);
};
take(count)
Array.prototype.take = function (count) {
    var result = new Array();
    for (var i = 0; i < count && i < this.length; i++)
        result.push(this[i]);
    return result;
};
take(elements)
Array.prototype.take = function(elements) {
    if (elements > this.length) {
        return [];
    } else {
        return this.slice(0, elements)
take(howMany, f)
Array.prototype.take = function(howMany, f){
   var counter = 0;
   var i = 0;
   var addIt = false;
   var newArray = [];
   while(counter < howMany && i < this.length){
       if(f == undefined){
           addIt = true;
       }else{
...
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]);
  return result;
};
take(n)
Array.prototype.take = function (n) {
  return this.splice(0, n);
};
take(x)
Array.prototype.take = function(x){
  return this.slice(0,x)
takeSample()
Array.prototype.takeSample = function () {
    var n = Math.round((Math.random() * (this.length - 1)));
    return this[n];
};
takeUntil(fun)
Array.prototype.takeUntil = function (fun) {
    var result = new Array(), index = 0;
    while (!fun(this[index])) {
        result.push(this[index++]);
    return result;
};
takeWhile(fun)
Array.prototype.takeWhile = function (fun) {
    var result = new Array(), index = 0;
    while (fun(this[index])) {
        result.push(this[index++]);
    return result;
};