babyachievement / notes

读书笔记
1 stars 1 forks source link

jQuery源码学习2:变量和函数 #3

Open babyachievement opened 8 years ago

babyachievement commented 8 years ago

匿名函数自执行, (function(window, undefined ){})(window); 1.查找速率 2.window压缩,可以将function(window,undefined)中的window可以写成e

undefined在某些浏览器中可以被修改,这里把undefined传递给函数,防止undefined被修改

"use strict" 表示使用严格模式 a = 10 var a = 10;

rootjQuery //赋值为jQuery(document)的变量1.文字说明变量用途2.便于压缩

readyList //跟DOM加载有关

core_strundefined = typeof undefined//存字符串形式的undefined,通过typeof 判断变量是否定义,而不是通过 == undefined来判断,== undefined在老版本浏览器中判断xml的节点的属性的时候可能不充分;统一使用typeof 进行判断

jQuery = window.jQuery $ = window.$ 为了防止jQuery $符号被其他框架使用了,将已经存在的jQuery和$屏蔽掉