Classes / Ladybug.Class


This is the base class for all the other Ladybug classes, it implements a simple inheritance layer for better encapsulation of the derived classes and a better foundation for object-oriented stuff.

The original code was written by John Resig (


So, how do you create and/or extend your own classes?

Take the Ladybug.Class or any derived class and extend it with your own properties and methods. That's all it takes:

// Create an object from the base class
Foo = Ladybug.Class.extend({
    bar: function() {

// Subclass your new object
Bar = Foo.extend({
    bar: function() {
        // Override at first
        console.log('I am ');
        // Then call parent method


function extend(options)

This is the core of the sub-classing mechanism, just take the base object and call extend to create a new constructor.

The passed options will define the extended-class methods and properties.

Go back to previous page