ctor
A simple and familiar prototypal system.
var Ctor = ; var Person = Ctor; var p = Person; console; // Hey, I'm Marco. But you can call me polotek var Employee = Person; var e = Employee; console; // 'Hello, my name is Marco. I work at Acme Novelties' // (p instanceof Person) === true// p.sayHello === Person.prototype.sayHello// (e instanceof Employee) === true// (e instanceof Person) === true// (e.__proto__ instanceof Person) === true
ctor
is a really simple prototypal object system that codefies a few simple constructs that I like.
- Don't use
new
. Think ofcreate
as your object factory. This follows nicely fromObject.create
. - There is a constructor for initializing your objects.
create
calls this on every object. - Instead of "inheritance", there is simple extension.
extend
creates a new object factory with the following behavior- Proper prototype chain is set up.
- The extended parent constructor will always be called implicitly. Initialization integrity is preserved.
- No other fanciness. No "super".