Magic Classes - Bringing OOP to Javascript

Are you a fan of object-oriented programming, and you wish you could make elegant, readable javascript classes? Magic Classes could be what you're looking for. There are a number of javascript files out there that provide similar functionality, and I'm not claiming that this is revolutionary. The goal of Magic Classes is simply to provide a very simple interface for classes, namespaces, and inheritance in Javascript.

Magic Classes is an open-source library released under the New BSD license. You can find the source code at its Google Code project page. Most of the inheritance code comes from an older version of the Ext JS library, back when it was LGPL and allowed its code to be shared by all.


Declaring a namespace that's 3 levels deep:


Defining a new base class with a constructor:

com.adamia.math.Class( 'Vector2D', {
      x : 0
    , y: 0
    , construct : function() {
        this.x = 1;
        this.y = 1;

Extending another class:

com.adamia.math.Class( 'Vector3D', 'Vector2D', {
      z: 0
    , construct : function() {;
        this.z = 1;

It's a pretty simple library, and I welcome (constructive) feedback for ways to improve it.



I'm Understand :) Obat Peninggi Badan Anak

I think this would be

I think this would be remarkable, bringing OOP to JavaScript is not taught in any of the exams like EX0-101 nor is it part of the traditional 70-646 exam so finding pros with such abilities should be harder and worth a lot of good.

Post new comment

The content of this field is kept private and will not be shown publicly.