Answers
function array_diff (arr1) {
var retArr = [],argl = arguments.length,k1 = '',i = 1,k = '',arr = {};
arr1keys: for (k1 in arr1) {
for (i = 1; i < argl; i++) {
arr = arguments[i];
for (k in arr) {
if (arr[k] === arr1[k1]) {
// If it reaches here, it was found in at least one array, so try next value
continue arr1keys;
}
}
retArr.push(arr1[k1]);
}
}
return retArr;
}
var arr0 = [1,3,4,5];
var arr = [1,3,5];
alert(array_diff(arr0,arr));
早安I.st
answered 12 years ago