Class: Class

FooTable. Class

This class is based off of John Resig's Simple JavaScript Inheritance but it has been updated to be ES 5.1 compatible by implementing an Object.create polyfill for older browsers.

new Class() → {FooTable.Class}

This base implementation does nothing except provide access to the FooTable.Class#extend method.


<static> extend(arg1, arg2) → {FooTable.Class}

Creates a new class that inherits from this class which in turn allows itself to be extended or if a name and function is supplied extends only that specific function on the class.
Name Type Description
arg1 object | string An object containing any new methods/members to implement or the name of the method to extend.
arg2 function If the first argument is a method name then this is the new function to replace it with.
A new class that inherits from the base class.

The below shows an example of how to implement inheritance using this method.

var Person = FooTable.Class.extend({
  construct: function(isDancing){
    this.dancing = isDancing;
  dance: function(){
    return this.dancing;

var Ninja = Person.extend({
  construct: function(){
    this._super( false );
  dance: function(){
    // Call the inherited version of dance()
    return this._super();
  swingSword: function(){
    return true;

var p = new Person(true);; // => true

var n = new Ninja();; // => false
n.swingSword(); // => true

// Should all be true
p instanceof Person && p instanceof FooTable.Class &&
n instanceof Ninja && n instanceof Person && n instanceof FooTable.Class
Copyright © 2016
Documentation generated by JSDoc 3.4.1 on 2017-07-06T21:37:42+02:00