JSFiddle - React, Tailwind, and code Playground
HTML
<div id="console"></div>
JavaScript
Foo = new Class({
// instance variable:
name: '',
// construtor:
initialize: function(name) {
this._setName(name);
},
// instance method:
getName: function(){
return this.name;
},
// protected instance method:
_setName: function(name) {
this.name = name;
}.protect()
});
// static variable:
Foo.bar = 'bar';
// static method
Foo.bar = function(){}
// instance object:
var myFoo = new Foo('my new name');
var theName = myFoo.getName();
var checkInstance = instanceOf(myFoo, Foo);
$('console').innerHTML += theName;
$('console').innerHTML += "<br />Is instance: " + checkInstance;