javascript模块简单写法

写法1:

(function (wd, doc) {
   
    var mw = {};
    mw.noConflict = noConflict;
    
    var _$ = wd.$;
    wd.$ = mw;

    function noConflict() {
        wd.$ = _$;
        wd.mw = mw;
        return mw;
    }
}
)(window, document);

写法2:

Xrm = function () {};

Xrm.Common = function () {
    var guidsAreEqual = function (guid1, guid2) {
        var isEqual;
        if (guid1 === null || guid2 === null || guid1 === undefined || guid2 === undefined) {
            isEqual = false;
        }
        else {
            isEqual = guid1.replace(/[{}]/g, "").toLowerCase() === guid2.replace(/[{}]/g, "").toLowerCase();
        }

        return isEqual;
    };

    return {
        GuidsAreEqual: guidsAreEqual
    };
}();

Xrm.Rest = function () {}();

Xrm.Soap = function () {}();

Xrm.Extension = function () {}();

 

你可能感兴趣的:(javascript模块简单写法)