//@ Capitalize string values in an array **/ Array.prototype.capitalize = function(){ return this.map(d=>{ if(typeof(d) == "string"){ return d.capitalize(); }else{ return d; } },[]); }; //@ ENABLE THE SIMPLE REPLACEMENT OF STRINGS THROUGH THE Array.replace **/ Array.prototype.replace = function( regex, replacement ){ return this.map( e => { if(typeof(e) == "string"){ return e.replace(regex,replacement) }else{ return e; } },[]); }; //@ ALLOW PROTOTYPICAL REMOVAL OF MULTIPLE ELEMENTS BY POSITION **/ Array.prototype.remove = function( rmIndices ){ if( Array.isArray(this) ){ for (var i = rmIndices.length -1; i >= 0; i--){ this.splice(rmIndices[i],1); } return this; }else{ return this; } }; //* COUNT INSTANCES OF A VALUE 'val' IN AN ARRAY **/ Array.prototype.count = function( val ){ if( val === undefined ){ return this.length; }else{ var counter = 0; this.forEach(function(ElementValue,ElementPosition){ if( val == ElementValue ){ counter++; } }); return counter; } }; //@ GET AN ARRAY OF UNIQUE VALUES AND THEIR FREQUENCY IN THE ORDER [item,frequency] Array.prototype.get_count= function(){ var itm, a= [], L= this.length, o= {}; for(var i= 0; i { return (deleteValue.indexOf( d ) === -1); } ); }; //@ GET THE SUM OF ALL VALUES IN AN ARRAY Array.prototype.sum = function(){ return this.reduce(function(a,b){ return (parseInt(a)||0)+(parseInt(b)||0); },0); }; //@ GET THE MEAN OF ALL VALUES IN AN ARRAY Array.prototype.mean = function(){ return ( this.reduce(function(a,b){ return (parseInt(a)||0)+(parseInt(b)||0) },0) / this.length ) };