It is easier with ES6. nodejs > 6.5 supports these features.
You should check out this link:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
The exact usage you want to use is implemented. However I would not recommend it.
The code below (taken from the link above) is a better practice because you don't have to remember in which order you should write the parameters.
function drawES6Chart({size = 'big', cords = { x: 0, y: 0 }, radius = 25} = {}) {
console.log(size, cords, radius);
// do some chart drawing
}
you can use this function by doing:
const cords = { x: 5, y: 30 }
drawES6Chart({ size: 'small', cords: cords })
This way functions get more understandable and it gets even better if you have variables named size, cords and radius. Then you can do this using object shorthand.
// define vars here
drawES6Chart({ cords, size, radius })
order does not matter.