OOjs

OOjs (short for "Object-oriented JavaScript") is a JavaScript library for working with objects. Key features include inheritance, mixins and additional utilities for working with objects and arrays. It also provides an EventEmitter mixin for event-driven programming, and a factory pattern for decoupling consumers of functionality from any particular class's implementation.

Core
Extend prototype and static methods and properties of child constructor from a parent constructor.

Copy prototype and static methods and properties to a child constructor from a parent constructor.

Initialize a base class to be inherited by, or mixed into, a child class. Only required for classes that do not inherit or mixin other classes.

Events
Allow event handlers to be attached, called when events occur, and detached.

The simplest way to attach and detach event handlers is by using the  and   methods.

When working with methods, use the  and   methods. Attached event handlers are called with arguments provided to the  method.

Registries and Factories
Provide a simple map interface for associating arbitrary data with a symbolic name. Used in place of a plain object to provide additional registration or lookup functionality. Commonly, subclasses of OO.Registry create and maintain specialized indexes during registration and provide alternative lookup methods which use these indexes.

Registry of classes with instantiation abstraction. Used for referring to classes by a symbolic name, which allows the class to be overridden without modification of calling code. Commonly, subclasses of OO.Factory, like OO.Registry, provide additional registration and lookup functionality; but in addition also often provide methods for accessing static information about registered classes.

Utilities
See the API documentation for a complete reference of available utilities.

Compatibility
OOjs requires an ECMAScript 3 compliant environment. Polyfills are used when needed to provide some ECMAScript 5 features. It is packaged to be run in either Web browsers or Node.js. While not dependent on jQuery, there is an optimized package that uses some of jQuery's features, resulting in less code being sent to the client.

Namespace
In the presence of a module system, such as when using with Node.js, OOjs exports all of its classes and methods. In other environments, such as Web browsers, a global variable is created named. You may access  the same way you would access   or

If you are using jsHint, you should add the following to your .jshintrc file.