js named parameters 1

js named parameters

myFunction({ param1 : 70, param2 : 175});

function myFunction({param1, param2}={}){
  // ...function body...

// Or with defaults, 
function myFunc({
  name = 'Default user',
  age = 'N/A'
}={}) {
  // ...function body...

Here is what the above code is Doing:
1. The function myFunction is defined with a single parameter, which is an object.
2. The object parameter has two properties, param1 and param2.
3. The function is called with an object as the argument.
4. The object passed as the argument has two properties, param1 and param2.
5. The function uses the object properties to perform some task.

Similar Posts