Skip to content

benekastah/JS-Class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#JS-Class


Please visit the documentation or the the unit tests (you know -- for examples).

My implementation is just an enhanced version of the typical javascript class patterns we were all taught in javascript school:

function Thing() {}

function Animal(type) {
  // stuff to initialize each instance here
  this.type = type;
}

Animal.prototype = new Thing();
Animal.prototype.constructor = Animal;
Animal.prototype.howl = function () { return this.type + " did a howl!!"; };
// etc.

But instead, you would write something more like this:

var Thing = Class.define({});

var Animal = Thing.extend({
  initialize: function (type) {
    // stuff to initialize each instance here
    this.type = type;
  } , howl: function () { return this.type + " did a howl!!"; }
});

You can see how building classes would be more pleasant in the second example. You should achieve similar performance with both approaches, as well. Look at the docs linked above to find out other goodies.

This project has no dependencies. If you just want to get a quick download, all you need is class.zip from the Downloads area. If that doesn't work for you, then you can find the minified source file in build/class.js (or build/class.min.js), and you can get the non-minified version in src/class.js.

Happy classing!

##Short (soon to be longer) list of javascript class implementations/ideas

Please contact me with links that can be added to the above.

About

Javascript Classes: Simple and to the point.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published