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
Post a Comment