// Immediately Invoked Function Expression
It should return “Error” or “Undefined” because delete operator deletes the x properties.
How the answer is 1 ?
// Immediately Invoked Function Expression
It should return “Error” or “Undefined” because delete operator deletes the x properties.
How the answer is 1 ?
Hi @theonlyritik_3b4a4a5eb9f6c783,
If executed this --> (function(x){ delete x; })(1);
Returns --> undefined, since there is no return statement hence value of x is deleted and hence this returns undefined . Side Note : we are not explicitly returning anything here.
If we execute --> (function(x){ delete x; return x; })(1);
Returns --> 1 , as it fetches the value of x. We are returning x explicitly here.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.