I'm sure this has been explained somewhere, but I have never found it so, here I go:
Let's say I have an object that contains functions move, attack, defend. How can I add them to a unit-object, without adding them one at a time, or adding a sub.object: units.commands = commands, rather: units = commands OR units.prototype = commands.
Another simple example:
var one = function () {
this.a = 1;
};
var two = function () {
this.z = 1;
};
var jee = new one(),
jee2 = new two();
jee = jee2;
console.log(jee); // Should have z AND a.