Nodejs Array Count valueCount(value)

Here you can find the source of valueCount(value)

Method Source Code

Array.prototype.valueCount = function (value) {
  var count = 0;/*from   w w  w . j  a va  2 s  .  co m*/

  for( var i = 0; i < this.length; i++) {
    if ( this[i] === value) {
      count++;
    };
  };
  return count;
};

Related

  1. countItem(item)
    Array.prototype.countItem = function (item) {
            return this.filter(function (i) {
                return i === item
            }).length;
    };
    
  2. 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;
    
  3. 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
    
  4. 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;
    
  5. first_n(count)
    Array.prototype.first_n=function(count) {
      var a=[];
      for(var i=0;i<count;i++) {
        a.append(this[i]);
      return a;
    
  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;
    };
    ...