Mittwoch, 15. Juni 2011

Javascript OOP Cheatsheet

var MyClass = function() {

    // self to get "this" in private / global / anonymous methods
    var self = this;

    // public var
    this.publicVar = 'public';
    // private var
    var privateVar = 'private';

    // public method
    this.publicMethod = function() {}
    // private method
    function privateMethod() {}
    // global method
    globalMethod = function() {}

}

Keine Kommentare:

Kommentar veröffentlichen