Deleting Getters and Setters (was Re: Controlling DontEnum...)

Mike Shaver mike.shaver at gmail.com
Mon Mar 17 15:08:21 PDT 2008


On Mon, Mar 17, 2008 at 5:36 PM, Brendan Eich <brendan at mozilla.org> wrote:
>  For backward compatibility with SpiderMonkey, one might like 2' to
>  make a getter that can be deleted.

That pattern is used in Firefox now (and perhaps elsewhere) to do lazy
initialization of expensive objects:

this.__defineGetter__("Debug", function() {
  var d = loadModule("debug.js");
  delete this.Debug;
  this.Debug = d;
  return d;
});

We could adapt, obviously, dunno if it's widely used on the web.

Mike



More information about the Es4-discuss mailing list