Guess the output #4
Question:
var x = 1;
var output = (function () {
delete x;
return x;
})();
console.log(output);
Output:
1
Explanation:
- In JavaScript, the delete operator is used to remove properties from an object.
- x is a variable, not a property of an object. The delete operator does nothing to x, so it remains unchanged.
- The IIFE (Immediately Invoked Function Expression) returns x, which is still 1.
- Therefore, console.log(output); prints 1.