function f2(x)
{
alert(x)
a=x.concat();
a[0]=a[0]+'ccc'
}

解决方案 »

  1.   

    <script>a=new Array()
    b=new Array()
    b[0]=new Array()
    b[0][0]=new Array()
    b[0][0][0]='aaa'
    b[0][0][1]='bbb'function f1()
    {
    f2(b[0])
    }function f2(x)
    {
    alert(x)
    a=x.concat()
    a[0][0]=a[0][0]+'ccc'
    }f1()alert(a)
    alert(b)</script>
    谢谢!我在实际中用的是3维数组,怎么办?
      

  2.   

    <script language=javascript>
    function clone (deep) {
      var objectClone = new this.constructor();
      for (var property in this)
        if (!deep)
          objectClone[property] = this[property];
        else if (typeof this[property] == 'object')
          objectClone[property] = this[property].clone(deep);
        else
          objectClone[property] = this[property];
      return objectClone;
    }
    Object.prototype.clone = clone;
    var a=new Array();
    var b=new Array();
    b[0]=new Array();
    b[0][0]='aaa';
    b[0][1]='bbb';function f1()
    {
    f2(b[0]);
    }function f2(x)
    {
    alert(x);
    a=x.clone();
    a[0]=a[0]+'ccc';
    }f1();alert(a);
    alert(b);</script>
      

  3.   

    dogfish(dogfish) ( ) 信誉:100 给的函数超级好用哈哈!严重感谢!想问一下,为什么我a=x以后,a变化时,x也跟着变呢?js对array的支持也太差了吧
      

  4.   

    因为a=x就是把x的handle给a