Params vs Arguments Javascript
function square(num) { // Params
console.log(num * num);
}
square(5); // Arguments
- Values passed in function calls are called Arguments
- Receiving the values passed in a function are called Params or Parameters
Q. What will be the output of the following code?
const fn = (a, ...numbers, x, y) => { // SyntaxError: Rest parameter must be the last formal parameter
console.log(x, y);
};
fn(5, 6, 3, 7);
- SyntaxError: Rest parameter must be the last formal parameter