Functions being first class objects, it seems their local data at some point must have properties, but I'm confused on when/how this happens.
Take for example:
var output = function(x){
var s = "string";
delete s;
return s + " " + x;
};
console.log(output("bean"));
outputs string bean
. I'm not sure if I expected it to delete s
or not I was just messing around, because I thought var
declared globally become a property of the window object.
I know delete
doesn't work on local variables, and it only works on object properties. And because Functions are objects, I'm wondering at what point does local data in a function become a "property"