So, I have a function with an object as a parameter:
function example(options = { param1: true, param2: 42 })
{
return options.param2;
}
The problem is, if I call the function with parameters like this:
example({ param1: false });
the default for options.param2
gets overridden and set to undefined
, even though it wasn't defined when the function was called. I realize why this is (the object is all one parameter so the entire thing gets set when you call the function), but is there any easy way to prevent this from happening, short of making all of the object parameters their own arguments in the function?