myFunction({ param1 : 70, param2 : 175});
function myFunction({param1, param2}={}){
// ...function body...
}
// Or with defaults,
function myFunc({
name = 'Default user',
age = 'N/A'
}={}) {
// ...function body...
}
function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
foo(1,2,3);
//1
//2
//3
function foo({first, second, third} = {}) {
console.log(first, second, third)
}
foo({
first: 1,
second: 2,
third: 3
})
// what are the parameters and arguments in javascript
// Function parameters are the names listed in the function's definition.
// Function arguments are the real values passed to the function.
function calculateArea(width, height){ // width and height are Parameters
console.log*=(width * height);
}
calculateArea(2,3); // 2 and 3 are Arguments