mediawiki-extensions-Visual.../modules/parser/core-upgrade.js
Subramanya Sastry 2ee1514552 Added mergeProperties function to Object.prototype
Change-Id: I50346029a9bd8a7d2cf954b0cca011f73a6fae07
2012-07-20 18:12:37 -05:00

20 lines
570 B
JavaScript

/**
* Progressive enhancement for JS core- define things that are scheduled to
* appear in the standard anyway.
*/
if(!Array.prototype.last) Object.defineProperty(Array.prototype, 'last', {
value: function() { return this[this.length - 1] }
});
/** Good-old monkey-patching to let us merge properties of another object into this one. */
if(!Object.prototype.mergeProperties) Object.defineProperty(Object.prototype, 'mergeProperties', {
value: function (o) {
var self = this;
Object.keys(o).forEach(function(k) {
self[k] = o[k];
});
return this;
}
});