So I have read the solution and still have questions that I’m trying to work through.
1 - I understand what call(arguments)
is doing, i.e. gets all the arguments passed in to the function. So I’m OK there.
2. Then slice
is returning the arguments in an array, as a new array object. So that’s OK.
3 - I do not understand what Array.prototype
is doing? I read this and I understand that the Array.prototype is like the ORIGINAL array from which all other arrays inherit properties etc. But I don’t get what purpose it is serving in this line of code.
Please help!
(You can ignore my code below; I was just messing around trying to understand arguments etc)
Your code so far
function destroyer(arr) {
// Remove all the values
// var args = Array.prototype.slice.call(arguments);
console.log(arguments.length);
// return arr;
}
// destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/seek-and-destroy