我一直在这个课程上做了几个小时的免费代码阵营,但是,我发现了一个我不明白的解决方案,并且我试图在每条记录上添加注释,以便在未来的参考文献中实现并理解它,而且我已经了解一些行,但我不明白这个代码的某些部分:在滤波器阵列上切换一个参数?
function destroyer(arr) {
// let's make the arguments part of the array
var args = Array.prototype.slice.call(arguments); // this would result into [[1, 2, 3, 1, 2, 3], 2, 3]
args.splice(0,1); // now we remove the first argument index on the array so we have 2,3 in this example
// I DO NOT UNDERSTAND THESE CODES BELOW
return arr.filter(function(element) {
return args.indexOf(element) === -1;
});
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
我已经检查的文件,我觉得很难理解,似乎在此示例中的代码有很大的不同。我将衷心感谢您的帮助!
要明确,代码的作品,你想知道为什么? – amflare
@amflare是的,我已经更新了这个问题。这是我的问题。 –
那你不明白吗? – Hamms