I was reading the JavaScript Docs I found the Array function section one Example that I could not understand properly. Because I am learning Programming.
function multiply(multiplier, ...theArgs){
return theArgs.map(x=> multiplier*x);
}
var arr = multiply(2,1,2,3);
console.log(arr);
Above example is giving
2,4,6
My first question why is used 3 dots(...) before function argument name (...theArgs) for? And How did it calculate 2,4,6? And the second Question is about rest parameter. What does the rest parameter use in Array Function?
I would be glad if anyone can give me some real-life object example to understand this Problem