JS.Class is a set of tools designed to make it easy to build robust object-oriented programs in JavaScript. It’s based on Ruby, and gives you access to Ruby’s object, module and class systems, some of its reflection and metaprogramming facilities, and a few of the packages from its standard library. It also provides a powerful package manager to help load your applications as efficiently as possible.

It supports all the major web browsers and a growing number of server-side platforms, including Rhino, Node.js and Narwhal. Wherever you’re using JavaScript, JS.Class makes building large programs a snap.

Features

JS.Class provides many of Ruby’s powerful features, including:

Its object system has been designed to exactly mimick the behaviour of Ruby, giving you a great deal of power when structuring large programs. It also provides a set of well-integrated data structures, all of which implement the powerful Enumerable API. If you like Ruby, you’ll feel right at home.

Download version 2.1

Version 2.1 builds on the 2.0 core and adds several new core features and packages. A quick tour of the new features:

Download JS.Class 2.1.5

Most code based on version 1.x will be compatible with this release, but there a few issues to be aware of. If you have code you cannot update to 2.x at present, 1.6 is still available:

Download JS.Class 1.6.3

Acknowledgements

JS.Class was initially inspired by, and borrows ideas from, these open-source projects:

The standard library has been influenced by techniques demonstrated in Pro JavaScript Design Patterns, and contains ports of a few standard Ruby modules.

JS.Class is © 2007–2010 James Coglan. You can find update announcements via my blog. The source code is hosted on Github.