JavaScript Class

My JavaScript Class notation.

by FiNGAHOLiC

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<ul id="log"></ul>

JavaScript

var log = function(str){
    var $ul = $('#log');
    var $li = $('<li />', {
        text : str
    });
    $ul.append($li);
};

var Human = function(){
    this.initialize.apply(this, arguments);
};

(function(){
    this.name = 'NONAME';
    this.age = 'NOAGE';
    this.initialize = function(name, age){
        this.name = name;
        this.age = age;
    };
    this.sayMyName = function(){
       log(this.name);
    };
    this.sayMyAge = function(){
       log(this.age);
    };
}).apply(Human.prototype);

var dylan = new Human('Dylan', 30);
var catherine = new Human('Catherine', 21);

dylan.sayMyName();
dylan.sayMyAge();

catherine.sayMyName();
catherine.sayMyAge();