I was looking at the Rebound javascript code and saw that the SpringSystem function is being extended with an empty object.
var SpringSystem = rebound.SpringSystem = function SpringSystem() {
this._springRegistry = {};
this._activeSprings = [];
this._listeners = [];
this._idleSpringIndices = [];
this._boundFrameCallback = bind(this._frameCallback, this);
};
extend(SpringSystem, {});
Where extend looks like:
function extend(target, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key];
}
}
}
What does the first extend achieve by extending an empty object? It's my understanding that an empty object has no hasOwnProperty(key) for anything.
What am I missing?
You are missing nothing, the code serves no purpose. It looks like a leftover from a class template, notice that other classes and all prototypes use this pattern.
That's also why it has been removed in 2014.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With