This example is equivalent to
var s;
function f() { return s; } // works fine though no `s` is defined yet !
s=1;
f(); // 1
delete s;
s=2;
f(); // 2
(function() {
var s=3;
f(); // 2 and not 3 which means lexical scoping is at play (?)
})();
Javascript variable declarations are hoisted to the top of their scope and are declared then. They're then defined where the user sets them to be. So you can reference a javascript variable before its declared in a function scope.
Also note that delete is generally used for properties on an object, not an object declared with var. Delete in this case has no effect, regardless of closure. See fiddle here: jsfiddle