javascript - Deleting a property of an object inside its definition; Why? -


looking @ recent google maps api loader source, i'm wondering purpose of following:

google.maps.load = function(apiload) {     delete google.maps.load;     ... 

why delete property of object, inside definition? suspect have performance increase, can't figure out how property can delete inside definition.

this ensure api loaded once. however, not throw useful error when function called second time, may cause exception.

here alternative solution throws more useful error.

google.maps.load = function() { throw new error("already loaded") }; 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -