Using delete in JavaScript getter / setter to delete the getter / setter

This is a question about how JavaScript getters and setters work.

Mozilla’s implementation of log4j as a JavaScript module (partial implementation, just the important parts needed for the intended use cases such as in Firefox Sync) contains the following getter/setter definition.

What does the ‘delete’ in the getter/setter do for you? What does that even mean? It seems to have the effect of making the first use have different results from following uses (but if so, how)?

get repository() {
  delete Log4Moz.repository;
  Log4Moz.repository = new LoggerRepository();
  return Log4Moz.repository;
},
set repository(value) {
  delete Log4Moz.repository;
  Log4Moz.repository = value;
},

100 thoughts on “Using delete in JavaScript getter / setter to delete the getter / setter”

  1. 903493 529712Spot lets start function on this write-up, I truly feel this fabulous site needs a fantastic deal a lot more consideration. Ill apt to be once again to learn far a lot more, appreciate your that info. 518478

    Reply