Skip to main content
Source Link
Peter
  • 101
  • 3

Larry has already mentioned avoiding adding your functions/variables to the global namespace. One way you can do this is to create an object and use it in your extend method like so -

(function (window, document, $) {
    "use strict";
            
    var myNamespace = myNamespace || {};

    // @param {string} name
    myNamespace.Product = function (name) {
        // do stuff
    };

    // etc
    ...

    $.extend(window, myNamespace);

}(window, document, jQuery));
Post Made Community Wiki by Peter