A bit of sugar for defining Objects and their prototypes.
var Animal = defineObject//a initialization method with side-effects//that luckily will not get called when the Animal object is inherited fromthislaunchRockets;prototype :sound: 'silence'weight: 0console.logthissound;;var Logger = defineObjectthislogHistory = ;prototype:thislogHistorypushmsg;console.logmsg;var Dog = defineObjectthisweight = weight;//Dog.parent.init.call(this); -- if you need to have access to the Animal initialization methodparent : Animal //inherits from Animalmixin : Logger //alternatively an array may be passed for multiple mixins ie [Logger, Events]prototype :sound : 'woof'DogparentProtovocalizecallthis; // Calling 'super' methods remains about the same.this.log"dog is vocalizing";console.log"I want what you're having.";this.log"dog is drooling";var dog = Dogcreate80; //Alternatively 'new Dog(80)' or 'Dog(80)'dogvocalize;dogdrool;console.log"History" doglogHistory;console.log dog instanceof Dog ;
Including a 'properties' field will simply pass the assigned literal to Object.defineProperties upon the creation of an object.
var O = defineObjectproperties :field :value : 'value'writable : false;var o = Ocreate;console.logofield;ofield = 'error'; //error