This is very brief overview of easy OOP that should be enough to start developing following easy OOP approach.

Class declaration

The sample below shows Zebra easy OOP usage and features: class and its methods declaration, constructors declaration, static field and method declaration.

// define own class
var MyClass = zebra.Class([
    // default constructor that call one argument constructor
    function() { this.$this(10); },

    // one argument constructor
    function(v) {
       // initialize class field
       this.value = v;
    },

    // class method
    function getValue() { return this.value; },

    // special method to define class static fields and methods 
    function $clazz() {
       this.staticField = 10;
       this.staticMethod = function() {  ...  };
    }
]); 

// usage
MyClass.staticMethod(); // call static method
MyClass.staticField     // access static field
// instantiation
var instance = new MyClass();
instance.getValue(); // return 10

Inheritance

Here is brief example of inheritance that demonstrates how parent class method can be overridden and overloaded.

// inherit MyClass class
var MyNewClass = new zebra.Class(MyClass, [
   // declare specific (two arguments) constructor
   function(a, b) {
      // call parent class constructor
      this.$super(a);
      this.b = b;
   },

   // overload parent "getValue" method with a method that gets 
   // one parameter as input
   function getValue(a) { return a; },

   // override parent class "getValue" method
   function getValue() {
       // call parent class "getValue()" method implementation 
       // and add 10
       return this.$super() + 10;
   }
]); 
  
// declared class usage
var instance = new MyNewClass(1, 2);
// call class methods 
instance.getValue()    // return 11
instance.getValue(100) // return 100

Anonymous class

Anonymous class is good approach to customize instantiated classes on the fly.

// create new instance of MyClass that is extended basic class with 
// new "setValue" method
var instance = new MyClass([
    function setValue(v) {
       this.value = v;
    }
]);

// call just added anonymous class method 
instance.setValue(100);