Nodejs Array Sub sub(other)

Here you can find the source of sub(other)

Method Source Code

Array.prototype.sub = function(other) {
    console.assert(this.length == other.length, 'sub: len(a) != len(b)');
    var ret = new Array(this.length);
    for(var i = 0; i < ret.length; i++)
        ret[i] = this[i] - other[i];//from  w ww . ja va 2s . c o  m
    return ret;
}

Related

  1. allSubArrays(width)
    Array.prototype.allSubArrays = function allSubArrays(width) {
      var w = width;
      var allArr = [];
      var i;
      var len;
      if (w) {
        w = Math.min(w, this.length);
        for (i = 0, len = this.length - w + 1; i < len; ++i ) {
          allArr.push(this.slice(i, i + w));
    ...
    
  2. listsub(array, sizediff)
    Array.prototype.listsub = function (array, sizediff) {
        if (!array)
            return null;
      var match = [];
        for (var i = 0; i < this.length; i++) {
            if (this[i].contains(array, sizediff)) {
                match.push(this[i]);
        return match;
    
  3. sub(a2)
    Array.prototype.sub = function(a2) {
      var l1 = this.length;
      var l2 = a2.length;
      var len = (l1 < l2 ? l1 : l2);
      var result = new Array(len);
      for (var i = 0; i < len; i++) {
        result[i] = this[i] - a2[i];
      return result;
    ...
    
  4. subList(start, end)
    Array.prototype.subList = function(start, end){
      return this.slice(start, end);
    
  5. subset(field, criterion)
    Array.prototype.subset = function (field, criterion) {
      var arr = new Array();
      for (var i=0 ; i<this.length ; i++) {
        if(this[i][field] === criterion) {
          arr.push(this[i]);
      return arr;
    
  6. subsetOf(other)
    Array.prototype.subsetOf = function (other) {
      for (var i = 0; i < this.length; i += 1) {
        if (other.indexOf(this[i]) === -1)
          return false;
      return true;
    };