码迷,mamicode.com
首页 > 其他好文 > 详细

jqeury源码之变量解析

时间:2017-12-05 01:08:05      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:源码   推荐   调用   ==   解析   ted   变量类型   tor   数据存储   

(function(window, undefined) {
  (21,94) :定义了一些变量和函数 jQuery = function() {};
  {
    rootjQuery :等于jQuery(document)
    readyList :DOM遍历
    _jQuery = window.jQuery; // 防冲突
    _$ = window.$; // 防冲突
    class2type: {}; // $.type() 时用到,判断变量类型
    core_deletedIds = []; // 2.x之前与数据存储相关,2.x版本之后基本没有作用了
    
    // 返回一个对象
    jQuery = function(selector, context){
      return new jQuery.fn.init(selector, context, rootjQuery);
    }
 
    【未完待续...】
 
  }
})(window)
 
【知识点梳理】
1、jQuery原型应用解析,即jQuery构造函数分析
function jQuery() {
  return new jQuery.prototype.init();
}
jQuery.prototype.init = function(){};
jQuery.prototype.css = function(){};
jQuery.fn = jQuery.prototype; // 源码96行
jQuery.fn.init.prototype = jQuery.fn; // 源码283行
// 调用方式
jQuery().css();
 
【小知识点梳理】
1、变量的使用
a = a + 10;  // 不推荐
var speed = 10; a = a + speed; // 推荐用法
2、判断 undefined
window.a === undefined; // 不推荐
typeof window.a === ‘undefined‘; // 推荐
3、window.document === document; // true
   docElem = document.documentElement; // ???

jqeury源码之变量解析

标签:源码   推荐   调用   ==   解析   ted   变量类型   tor   数据存储   

原文地址:http://www.cnblogs.com/shihangbo/p/7979504.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!