jQuery源码解析(1)

来源:互联网 发布:ubuntu ntp服务器设置 编辑:程序博客网 时间:2024/06/11 11:33


JQuery文件的开头代码:

!function(d, c) {"object" == typeof module && "object" == typeof module.exports ? module.exports = d.document ? c(d, !0) : function(b) {if (!b.document) {throw new Error("jQuery requires a window with a document")}return c(b)} : c(d)}("undefined" != typeof window ? window : this, function(a, b) {。。。。。。。});

以上一段代码是自执行代码结构,等价于:

function  AAAA(a, b) {    "object" == typeof module && "object" == typeof module.exports ? module.exports = a.document ? b(a, !0) : function(a) {        if (!a.document) throw new Error("jQuery requires a window with a document");        return b(a)    }: b(a)} function  BBB(a, b) {。。。}var paramA="undefined" != typeof window ? window: this;AAAA(paramA,BBB);









原创粉丝点击