In console:
>var t = function(undefined){
return undefined
}
>t("ss")
>"ss"
I dont get why it returns a string. Though
void(0)
always returns undefined
In console:
>var t = function(undefined){
return undefined
}
>t("ss")
>"ss"
I dont get why it returns a string. Though
void(0)
always returns undefined
By setting the parameter name to undefined
in the function expression, you mask the global variable that is also named undefined
.
When you pass "ss"
as the first argument, it is assigned to the local variable undefined
.
When you return undefined
, you return the value of the local variable undefined
which is "ss"
since that is what you assigned to it.