随笔分类 - 源码解读
摘要://根据ID返回dom元素 2 var $ = function(id){return document.getElementById(id);} 3 //返回dom元素的当前某css值 4 var getCss = function(obj,name){ 5 //ie 6 if(obj.currentStyle) { 7 return obj.currentStyle[name]; 8 } 9 //ff10 else {11 var s...
阅读全文
摘要:function Queue() { this.data = []; } Queue.prototype = { processTime: 20, add: function (fn, params, context) { this.data.push({ fn: fn, params: params, context: context }); }, start: functio...
阅读全文
摘要:var origDoSomething = Thing.prototype.doSomething;Thing.prototype.doSomething = function() { var start = Date.now(); var result = origDoSomething.apply(this, arguments); console.log((Date.now() - start) + 'ms', x, y, result); return result;}
阅读全文
摘要:slice = Array.prototype.slice,// Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { if ( typeof context === "string" ) { var tmp = fn[ context ]; context = fn; fn = tmp; } // Quick...
阅读全文
摘要:1 (function() { 2 3 // 创建一个全局对象, 在浏览器中表示为window对象, 在Node.js中表示global对象 4 var root = this; 5 6 // 保存"_"(下划线变量)被覆盖之前的值 7 // 如果出现命名冲突或考虑到规范, 可通过_.noConflict()方法恢复"_"被Underscore占用之前的值, 并返回Underscore对象以便重新命名 8 var previousUnderscore = root._...
阅读全文
浙公网安备 33010602011771号