var data={ id: [1,1,1,10,123,4531], v:[123,123,53,223,11,11,11] }, _v = data.v, vinit; document.write(data.v+'<br>'); for(var i=0;i<_v.length;i++){ vinit = _v[i]; for(var j=i+1; j<=_v.length;j++){ if(_v[j]===vinit){ delete _v[j]; } } }; document.write(data.v);
var data={ id: [1,1,1,10,123,4531], v:[123,123,53,223,11,11,11,...] }, _v = data.v, vinit; for(var i=0;i<_v.length;i++){ vinit = _v[i]; for(var j=i+1; j<=_v.length;j++){ if(_v[j]===vinit){ delete _v[j]; } } }
the above code is only for v, but you can reduce duplicate elements for id at the same time by introducing a few more variables
in the fragment you will see that in the second line there are additional commas that indicate that these elements have been deleted.
source share