Here is the function, password
is mandatory but other id
and name
have default values:
function name({id = null, name = 'user', password}) { }
Results:
name(); //throws error as expected
name({}); //passes 'password' as 'undefined' - should've thrown error
How can I make this function throw an error if password
is not provided using ES6 functionality?