Just check for varName === undefined
.
In older browsers it was possible to assign an alternate value to the global undefined
variable causing that test to fail, but in ES2015+ that’s now impossible.
Note that there’s no way to distinguish explicitly passing undefined
as a parameter from leaving the parameter out altogether other than by looking at arguments.length
.