JavaScript function definition inside a with() block: Firefox is the oddball

I came across yet another browser discrepancy with a rather obscure scenario: Accessing an object property from a function declaration within a with block for that object.

var obj = { a: 1 };

with (obj) {
    function foo() {
        return typeof a;
    }
}

alert(foo()); // alerts "number" on Firefox, "undefined" on others

This exposes the object properties to the function scope only on Firefox. On all other browsers that I’ve tested with (IE, Safari, Opera and Chrome), the property isn’t visible inside the function.