zoukankan      html  css  js  c++  java
  • jquery源码笔记(二): 定义的变量,

    jquery中定义的变量,1、防止污染全局变量,2、自定义变量有助于压缩优化,3、有助于后期维护

    rootjquery ,  jquery的根目录jquery(document),

    core_strundefined= typeof undefined,      core_strundefined 存的就是string类型的 undefined  

    判断a是不是不存在: 一般判断方法,有2种:

    window.a ==undefined;        //只使用这个  可能在IE中不行,
          typeof window.a  =="undefined";    //IE10以下 适合使用这个方法,所以这个是全兼容的

    将window中的属性 存储在变量中,有利于 压缩

       location = window.location,
        document = window.document,
        docElem = document.documentElement, //html标签

    防止冲突,jquery被别人使用了,被重写了

    _jQuery = window.jQuery,

    防止冲突,$被别人使用了,被重写了

    _$ = window.$,

    对类型进行判断:

    class2type = {},    {'[Obejct String]':'string','[Object Array]':'array' }

    一个空数组

    core_deletedIds = [],

     数组的方法名 、字符串的方法名  保存在变量中

        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,    

    正则表达式:

    // Used for matching numbers   匹配数字: 正数、负数、科学计数法
        core_pnum = /[+-]?(?:d*.|)d+(?:[eE][+-]?d+|)/.source,
    
        // Used for splitting on whitespace   用空格 分开单词
        core_rnotwhite = /S+/g,
    
        // A simple way to check for HTML strings
        // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
        // Strict HTML recognition (#11290: must start with <)
        rquickExpr = /^(?:s*(<[wW]+>)[^>]*|#([w-]*))$/,   匹配 标签<>和 id
    
        // Match a standalone tag
        rsingleTag = /^<(w+)s*/?>(?:</1>|)$/,   匹配一个成对的空标签  <p></p>   <div></div> 
    
        // Matches dashed string for camelizing
        rmsPrefix = /^-ms-/,   IE中的前缀 -ms 转成: Ms  
        rdashAlpha = /-([da-z])/gi, 转大小写   -left  转成 Left

    转驼峰标识的 回调函数

    fcamelCase = function( all, letter ) {
            return letter.toUpperCase();
        },

    DOM加载成功 触发的方法

    completed = function() {
            document.removeEventListener( "DOMContentLoaded", completed, false );
            window.removeEventListener( "load", completed, false );
            jQuery.ready();
        };
  • 相关阅读:
    Nginx软件优化
    分布式文件系统---GlusterFS
    内建DNS服务器--BIND
    ESXI 6.5 从载到安装
    在Linux下写一个简单的驱动程序
    TQ2440开发板网络配置方式
    虚拟机Linux下找不到/dev/cdrom
    求最大公约数
    strcmp的源码实现
    转:嵌入式软件工程师经典笔试题
  • 原文地址:https://www.cnblogs.com/a-lonely-wolf/p/5700379.html
Copyright © 2011-2022 走看看