I recently learned about the ES6 function, which allows you to define the parameters of a function with a deconstructing object. In this way
function makeGenerator({type, max}) {
return something
}
I really liked this approach because it allowed me to see the arguments needed for the function, where it is defined and where it is called. (Really good for self-documenting code!)
I used it along with the default arguments:
function makeGenerator({type = "natural", max = 10})
This works great!
But...
Sometimes I would like, as a rule, for debugging purposes (but not limited to this) to get a summary of all the function arguments. However:
function makeGenerator({type = "natural", max = 10}) {
console.log(arguments[0])
}
makeGenerator({type = "fibanacchi"});
will output:
{type: "fibanacchi"}
, max, , 10, , .
, - :
{type: "fibanacchi", max: 10}
, , .
?