Nodejs Array Join join()

Here you can find the source of join()

Method Source Code

//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

function foo(arr)
{
    var o2 = o;/*w  ww.  ja  va2  s . c om*/
    var y = 100;
    for (var i =0;i<10;i++)
    {
        y += o2.x + arr;
    }
    WScript.Echo(y);
}
var o = {x:1};
var arr = [1,2,3,4]
Array.prototype.join = function(){ return o.x+=100; }
foo(arr);

Related

  1. join(separator)
    Array.prototype.join = function(separator) {
      var s = new String();
      for (var i = 0, len = this.length; i < len; i++) {
        s += (i > 0) ? separator : "";
        s += (typeof this[i] == "object" && this[i].constructor === Array) ? this[i].join(separator) : this[i];
      return s;
    };
    
  2. joinModel(id_app,model,joinFields,fn)
    Array.prototype.joinModel = function(id_app,model,joinFields,fn){
      var array = this;  
      async.map(array,function(a,callback){
        async.map(joinFields,function(join,callback){
          var akey = join.akey;
          var bkey = join.bkey;
          var avalue = a[akey];
          var query = {id_app:id_app};
          query[bkey] = avalue;
    ...
    
  3. joinsub(array, sizediff)
    Array.prototype.joinsub = function (array, sizediff) {
      if (!array)
        return null;
      var match = [];
      for (var i = 0; i < this.length; i++) {
        if (this[i].contains(array, sizediff)) {
          for (var j = 0; j < this[i].length; j++) {
            if (array.indexOf(this[i][j]) == -1) {
                match.push(this[i][j]);
    ...