Nodejs Utililty Methods Array Push Unique

List of utility methods to do Array Push Unique

Description

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

Method

pushUniquely(e)
Array.prototype.pushUniquely = function(e){
  for(var i=0;i<this.length;i++){
    var ae = this[i];
    if(ae instanceof Array && e instanceof Array){
      if(ae.isEqual(e)) return i;
    }else{
      if(ae==e) return i;
  return this.push(e)-1;
pushReplace(pattern)
Array.prototype.pushReplace = function(pattern){
  var args = Array.prototype.slice.call(arguments, 1);
  this.push(pattern.replace(/\{(\d+)\}/g, function(pattern, index){
    return args[index].toString();
  }));
  return this;
};
push_unique(value)
Array.prototype.push_unique = function (value) {
  if (!this.in_array(value)) {
      this.push(value);
};