Module Pattern - It stays out of the global namespace, provides publicly addressable API methods, and supports protected or “private” data and methods along the way.

var myFunc = (function() {
    var privateProperty = 10;

    return {
        print: function() {
            console.log(privateProperty);
        },
        assign: function(a) {
            privateProperty = a;
        }
    }
})();

myFunc.print(); //10
myFunc.assign(100);
myFunc.print(); //100

The private variables can only be accessed from within the anonymous function itself or from within a member of the returned object. This is through the power of closuers.

References