Is there a known reason why passing in null
as a parameter in ES6 does not use the default parameter when one is provided?
function sayHello(nam
That's just how default parameters are defined in the spec. See MDN: (emphasis mine)
Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed.
null
is neither no value, nor undefined
, so it doesn't trigger the default initialization.