Nodejs Array Count first_n(count)

Here you can find the source of first_n(count)

Method Source Code

Array.prototype.first_n=function(count) {
  var a=[];/* www. java2  s. c  om*/
  for(var i=0;i<count;i++) {
    a.append(this[i]);
  }
  return a;
}

Related

  1. countForBreeding()
    Array.prototype.countForBreeding = function() {
      var numToBreed = 0;
      for (var i = 0; i < this.length; i++) {
        if (this[i].noCalvesYet()) {
          numToBreed++;
      return numToBreed;
    };
    ...
    
  2. countItem(item)
    Array.prototype.countItem = function (item) {
            return this.filter(function (i) {
                return i === item
            }).length;
    };
    
  3. countOf(pValue)
    Array.prototype.countOf = function (pValue){
        var count   = 0;
        var lArray  = this || [];
        var lLength = lArray.length
        for (var i = 0 ; i < lLength; i++){
            if (lArray[i] == pValue){
                count++;
        return count;
    
  4. countType(type)
    Array.prototype.countType = function (type) {
      var count = 0
      for( var i = 0, x = this.length; i < x; i++) {
        if (this[i] === type) {
          count++
      return count
    
  5. element_count()
    Array.prototype.element_count = function(){
      var count = 0;
      for(var i=0; i<this.length; i++){
        if(this[i] != undefined){
          count++;
      return count;
    
  6. valueCount(value)
    Array.prototype.valueCount = function (value) {
      var count = 0;
      for( var i = 0; i < this.length; i++) {
        if ( this[i] === value) {
          count++;
        };
      };
      return count;
    };
    ...
    
  7. valueCount(value)
    Array.prototype.valueCount = function (value) {
      var count = 0;
      for( var i = 0; i < this.length; i++) {
        if ( this[i] === value) {
          count++;
        };
      };
      return count;
    };
    ...