prototype object. When object instances are created using the
new keyword in front of a function they reference all the properties and methods of that function's prototype. As such, all properties of the prototype object are also properties of that object.
Even though a function automatically comes with a prototype, a function may actually use any object as its prototype. Thus, we can mimic a classical inheritance strategy by setting the prototype of some function to an instance of some other function, its "superclass".
Function#extend([ properties ])
Function#extend is used to create an inheritance hierarchy that automatically sets up the prototype chain from one constructor function to another.
var Person = Object;var Employee = Person;var buzz = 'Buzz' 'astronaut';buzz; // Hi, my name is Buzz. I'm an astronaut!Employeeparent; // PersonEmployee; // truePerson; // trueEmployeeancestors; // [ Person, Object ]Employee; //trueObject; // true
Under the hood
Function#inherit to setup the prototype chain.
Object.defineProperties. Please see kangax's excellent ECMAScript 5 compatibility table for information on which browsers support ES5.
$ npm install monterey
Then, in your node program use
require('monterey') to set it up.
In browsers, just include
dist/monterey.min.js using a
Please file issues on the issue tracker on GitHub.
To run the tests in node:
$ npm install $ npm test
To run the tests in Chrome:
$ npm install $ npm run test-browser