var aaa=function(){return 123;}();
console.log(aaa);
var bbb={num:100}.num;
console.log(bbb);
console.log(aaa);
var bbb={num:100}.num;
console.log(bbb);
2016-09-28
ajQuery.fn = ajQuery.prototype = {
name: 'aaron',
init: function(selector) {
this.selector = selector;
return this;
},
say : function() {
$("#aaron").html(this.name)
}
constructor: ajQuery
}
ajQuery.fn.init.prototype = ajQuery.fn
$$().say()
例子中如果改成上面的代碼,這樣還好理解
name: 'aaron',
init: function(selector) {
this.selector = selector;
return this;
},
say : function() {
$("#aaron").html(this.name)
}
constructor: ajQuery
}
ajQuery.fn.init.prototype = ajQuery.fn
$$().say()
例子中如果改成上面的代碼,這樣還好理解
2016-09-28
“這個函數(shù)必須在你導入jQuery文件之后,并且在導入另一個導致沖突的庫之前使用。”這句話不明白呀,是不是寫錯了,不應該是先引入可能有沖突的庫,然后再引入jQuery,這樣才存在舊的命名空間和新的命名空間之說
2016-09-26
總結:全局變量是魔鬼, “自執(zhí)行”函數(shù)可以有效的保證在頁面上寫入JavaScript,而不會造成全局變量的污染,通過小括號,讓其加載的時候立即初始化,這樣就形成了一個單例模式的效果從而只會執(zhí)行一次。是不是應該是這樣的
2016-09-26
var object = optionsCache[options] = {};
這行代碼很精妙啊,假設傳遞給createOptions()方法的參數(shù)是"memory unique",則緩存會記錄optionsCache["memory unique"] = object = {memeory:true,unique:true};
當再次執(zhí)行optionsCache("memory unique")的時候,會直接從optionsCache中取值,而不會再次執(zhí)行jQuery.each()函數(shù)。
這行代碼很精妙啊,假設傳遞給createOptions()方法的參數(shù)是"memory unique",則緩存會記錄optionsCache["memory unique"] = object = {memeory:true,unique:true};
當再次執(zhí)行optionsCache("memory unique")的時候,會直接從optionsCache中取值,而不會再次執(zhí)行jQuery.each()函數(shù)。
2016-09-19
針對oClick2(),可以去看看函數(shù)定義和函數(shù)表達式,函數(shù)定義的話整個可以提升,函數(shù)表達式,只有表達式指向的引用會提升
2016-09-14