In this post, It says that the delete operator does not work on functions.
The invocation of the delete operator returns true when it emoves a property and false otherwise. it’s only effective on an object’s properties, it has no effect on variable or function names.
But consider this code:
delete Date;
new Date(); // thros an reference error
To make sure that Date is a function constructor, I wrote:
typeof Date; // "function"
This piece of code verifies that Date is a constructor, not an object. If the delete operator work on this particular type of function constructor, it should work on my constructor also. But it doesn't.
function a(){}
var b = new a();
delete a; // false
So, the delete operator did not delete my function constructor but for some reason, it deleted the Date constructor. Can someone clear this confusion of mine?