I am reading through the MDN article about arrays in javascript here, and I have a question about this specific code block:
function double(number) {
return number * 2;
}
const numbers = [5, 2, 7, 6];
const doubled = numbers.map(double);
console.log(doubled); // [ 10, 4, 14, 12 ]
I don't understand the use of "number". It is being passed into the function, and only exists within the function, so how does it know that it is working on the array called "numbers". I am just trying to understand the relation/link between the function and the array/.map method.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/LnEeWQd
Comments
Post a Comment