jQuery extend
http://api.jquery.com/jquery.extend/
HTML
<p>http://api.jquery.com/jquery.extend/</p>
<div id="log"></div>
JavaScript
/* our code is like
Document.prototype = jQuery.extend(Document.prototype, {
getKeyString : function() {
return this._mEntity.getKeyString(this._mEntity);
},
*/
var normalcat = {
size : "small",
color: "black"
};
var supercat = {
color: "red",
superpower: "fly"
};
console.log("normalcat before", normalcat);
// !!! take care!!! normalcat will be changed!!!
var mixedcat = $.extend( normalcat, supercat );
console.log('mixedcatmixedcat',mixedcat);
console.log("normalcat after", normalcat);
console.log("supercat", supercat);
console.log("mixedcat", mixedcat);