This code will output undefined
as output. The delete
operator is used to delete a property from an object. Here, x
is an object which has foo
as a property. From the self-invoking function, we are deleting the foo
property of object x
. After deletion, we are trying to reference the deleted property foo
, which results in undefined
.
Source
xxxxxxxxxx
var x = { foo : 1};
var output = (function() {
delete x.foo;
return x.foo;
})();
console.log(output);
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment