Let's try another script. The following code defines the fun local variable, which is assigned an anonymous function that returns a number:
var fun = function() { return 42; }
You can then call fun() like a regular function, as follows:
Now, let's look at what happens if we delete the definition of fun from the script, but still keep the invocation:
We still get the same result even though we didn't define what fun means! This is because any variables at the top scope become properties of the global object. The state of ...