Hello campers,
I am having a hard time understanding the logic behind the way parameters are passed within functions (in this particular case within the “filter” context). I have seen this hundreds of times, so I think it is a fundamental part of JS that will unlock for me (and hopefully for others) future challenges and projects. I am going through the “Seek and Destroy” challenge, and I see in the “Hint” page the following piece of code (which I pasted and don’t claim as my own). My interest here is on the “function (val)” part. Where does the “val” parameter come from, where does it get its content from and how is it evaluated? Thank you.
function destroyer(arr) {
var args = Array.from(arguments).slice(1);
return arr.filter(function(val) {
return !args.includes(val);
});
} a