Michał Kalbarczyk

Javascript Class Builder

1 January 2007

Javascript Class Builder

Simple (yet) function that make pseudo class creation simple.

Example class:

Class({
  clazz: {
    clazz: function( smth ){
      this.foobar = smth;
    },
    foobar: 'default',
    getFoobar: function(){
      return this.foobar;
    }
  }
})

foo = new clazz('123');
bar = new clazz();

alert( foo.getFoobar() );
alert( bar.getFoobar() );

Notice that constructor have same name as class name :) You can download it here.