Nodejs Array Value superJoin(value)

Here you can find the source of superJoin(value)

Method Source Code

/**//from w w  w . j  a va2s.  c  o  m
 * Created by Moment on 2015/8/24.
 */

isNullOrEmpty=function(obj) {
    if (obj == undefined || obj == null || obj == "") {
        return true;
    }
    else {
        return false;
    }
}

Array.prototype.superJoin=function(value){
    var ids="";
    for (var i=0,n=this.length; i<n; i++){
        ids=ids+this[i].id+value;
    }
    ids=ids.substr(0,ids.length-1);
    return ids;
};
====
Array.prototype.indexOf = function(value){
    for (var i=0,n=this.length; i<n; i++){
        if (this[i] === value){
            return i;
        }
    }
    return -1;
};

Related

  1. pad(minSize, val)
    Array.prototype.pad = function(minSize, val) {
        var padded = new Array();
        for (var i = 0; i < this.length; i++) {
            padded.push(this[i]);
        while (padded.length < minSize) {
            padded.push(val || null);
        return padded;
    ...
    
  2. plumRemove(elemVal)
    Array.prototype.plumRemove = function(elemVal){
      var i = this.indexOf(elemVal);
      if(i>-1){
        this.splice(i, 1);
    };
    
  3. query(field, operator, value)
    Array.prototype.query = function (field, operator, value) { 
        if (operator=="contains"){
            value = value.toLowerCase();
          return this.filter(function (item){
           return item[field].toLowerCase().indexOf(value) !== -1;   
        });
      else if(operator == "==") {
        return this.filter(function (item){
    ...
    
  4. resize(newSize, defaultValue = 0)
    Array.prototype.resize = Array.prototype.resize || function(newSize, defaultValue = 0) {
        while (newSize > this.length) {
            this.push(defaultValue);
        this.length = newSize;
    };
    
  5. resizeMatrix(rowsSize, columnsSize, defaultValue = 0)
    Array.prototype.resizeMatrix = Array.prototype.resizeMatrix || function(rowsSize, columnsSize, defaultValue = 0) {
        while (rowsSize > this.length) {
            var row = [];
            row.resize(columnsSize, defaultValue);
            this.push(row);
        this.length = rowsSize;
    };
    
  6. toggleValue(value)
    Array.prototype.toggleValue = function (value) {
        var index = this.indexOf(value);
        if (index === -1) {
            this.push(value);
        else {
            this.splice(index, 1);
    };
    ...
    
  7. trim(value)
    Array.prototype.trim = function (value) {
      var array = this.slice(0); 
      while (array.length > 0 && array[0] === value) {
        array.shift();
      while (array.length > 0 && array[array.length - 1] === value) {
        array.pop();
      return array;
    ...
    
  8. tw_indexOf(val)
    Array.prototype.tw_indexOf = function(val) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == val) return i;
        return -1;
    };
    Array.prototype.tw_remove = function(val) {
        var index = this.indexOf(val);
        if (index > -1) {
    ...
    
  9. unset(value)
    Array.prototype.unset = function (value) {
        if (this.indexOf(value) !== -1) { 
            this.splice(this.indexOf(value), 1);
    };