How to escape implicit 'with (this)' of a method body
P T Withington
ptw at pobox.com
Mon Jul 28 17:28:05 PDT 2008
On 2008-07-28, at 18:22EDT, Michael Haufe wrote:
> /function foo () { return 'global'; }
>
> class bar {
> function foo () { return 'local'; }
>
> function zot () {
> // How can I call the global foo from here?
> without (this) { foo(); }
> }
> }/
>
> You could use window["foo"](); or whatever the global object is
> named in the environment
Shouldn't there be an es4 standard way of doing it, without relying on
a particular environment?
class bar {
function foo () { return 'local'; }
// I guess this should work, but it seems rather kludgey
static function globalfoo (...) { return foo(...); }
function zot () {
globalfoo();
}
More information about the Es4-discuss
mailing list