我有以下代码:
$.grep(arrayPintar, function(el) {
if ($.inArray(el, arrayVariables) == -1)
difference2.push(el);
// arrayPintar.pop(el);
var identificador = difference2.pop();
if ((identificador != null) || (arrayVariables.length == 0)) {
$("div#container div#" + identificador + "").remove();
}
});
我无法从#container
中删除所有元素,因为当我的数组变量为空时,grep
会返回执行错误(length can not be null
)。
有没有其他方法来比较两个数组并返回不同的元素?
提前感谢您的时间和精力。