I have a code which is expected to return 'undefined' or any error but it gives output as mentioned.
let i = (x, c) => {
c(x);
};
i(20, (undefined) => {
let j = undefined;
console.log(j);
});
function y(undefined) {
let a = undefined;
console.log(a);
}
y(90);
How reserved words works and change behavior if used in function arguments?
undefined is not a reserved word.
It is a global, readonly variable.
Nothing stops you defining another variable with the same name in a narrower scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With