jquery源码细节知识点21-94

(function(window,undefined){})(window)--为什么传windw:好处,1.更好锁定和查找2.有利于压缩吧,undefined--因为ie的值不同下,为了防止外面修改,进行传参的方式

readyList--这个变量和dom加载有关

core_strundefined = typeof undefined,是一个字符串的变量

小知识点:判断windo下属性是否存在(2)

1.window.a==undefined;--在ie下不支持

2.typeof window.a=='undefined';全兼容的

变量存储:有利于压缩
 location = window.location,--网站信息
 document = window.document,--
 docElem = document.documentElement,--html标签

jquery的防冲突和别的库中变量$();
 _jQuery = window.jQuery,

_$ = window.$,

class2type = {},--这个变量使用$.type();类型判断;

core_deletedIds = [],--缓存数据有关的,在2.0空数组

core_concat = core_deletedIds.concat,
 core_push = core_deletedIds.push,
 core_slice = core_deletedIds.slice,
 core_indexOf = core_deletedIds.indexOf,
 core_toString = class2type.toString,
 core_hasOwn = class2type.hasOwnProperty,
 core_trim = core_version.trim,--去掉空格下的方法--高版本下不考虑ie6-8直接使用

数组的方法

jQuery = function( selector, context ) {
  
  return new jQuery.fn.init( selector, context, rootjQuery );
 },

衍生的知识点:普通写面对象--写一个构造函数在构造函数上写原型

function Aaa(){}'

Aaa.prototype.init=function(){};

Aaa.prototype.css=function(){};

var al=new Aaa();

al.init();

al.css();

jquery下的写的面向对象:

function jquery(){

  return new Jquery.prototype.init();

};方便的解决原生js中写实例的繁琐;

jQuery.protytype.init.prototype=jquery.prototye;---出现了对象的引用关系;

jquery.prototype.init=function(){};

jquery.prototype.css=function(){};

jquery().css();

你可能感兴趣的:(jquery源码细节知识点21-94)