title: writting own array constructor function, assuming array object dosen't exist.. all fine but this.unshift() isn't working properly
body: <p>writting my own array constructor function, assuming array object dosen't exist.. all functions are working as i am expecting but this.unshift() isn't working properly.. when i invoking tostring() after calling unshift() it's giving me unexpected result...</p>
  
  <pre><code>function myArray() {
    var i = 0;
    this.length = 0;
    var args = arguments;
    while (args[i] !== undefined) {
      this[i] = args[i];
      this.length++;
      i++;
    }
  
    this.tostring = function() {
      var result = args[0];
      for (var k = 1; k &lt; args.length; k++) {
        result += "," + args[k];
      }
      return result;
    }
  
    this.push = function(push) {
      this[args.length] = push;
      args[args.length] = push;
      args.length++;
      return++ this.length;
    }
  
    this.pop = function() {
      var pres = args[args.length - 1];
      delete args[args.length - 1];
      delete this[args.length - 1];
      args.length--;
      this.length--;
      return pres;
    }
  
    this.shift = function() {
      var shiftres = args[0];
      var x = 0;
      var y = 1;
      while (args[x] !== undefined) {
        this[x] = args[y];
        args[x] = args[y];
        x++;
        y++;
      }
      this.length--;
      args.length--;
      return shiftres;
    } ** this.unshift ** = function() {
      var args2 = this.unshift.arguments;
      var t = 0;
      var z = 0;
      while (args2[t] !== undefined) {
        this[t] = args2[t];
        args[t] = args2[t];
        t++;
        this.length++;
        args.length++;
      }
      while (args[z] !== undefined) {
        this[t] = args[z];
        args[t] = args[z];
        t++;
        z++;
      }
      return args2;
    }
  
  }
  </code></pre>