Module Pattern

by someprimetime

CSS

body {
    height: 1000px;
}

JavaScript

var MyThingy = (function () {

    doSomethingCool : function() {
        alert('yo!');
    }

    function internalSomething() {
        alert('doing somethign internally');
    }

    function anotherNiftyThing() {
        // Note that within the scoping function, functions can
        // call each other direct.
        doSomethingCool();
        internalSomething();
    }

    return {
        doSomethingCool: doSomethingCool,
        anotherNiftyThing: anotherNiftyThing
    };
})();
MyThingy.doSomethingCool();