1

请帮我解决下一个问题。

var a = _b; //_b and _c is arguments. _b is array of objects (length = 1), _c is integer value
if (a.length != 0)
{
   $.each(a,function(k,v){
     if (v.c!= _c)
       a.splice(k,1);//here a becomes empty, but _b becomes empty too. i don't know why.
   }); 
   if (a.length != 0){
      _b = a;
   }
}

我究竟做错了什么?

4

1 回答 1

3

该变量a是对数组的引用_b,而不是副本,因此也可以a清空_b

于 2013-03-06T05:16:33.533 回答