function demo(){框架
var a = b = c = 9; // b,c全局變量 a局部變量函數
}工具
demo();動畫
console.log(b)orm
命名空間get
var Shop = {} //頂層命名空間io
Shop.user = {} //用戶模塊console
自執行函數function
(function(){form
window.shop = {};
window.shop.user = {};
})()
//把本身基類的不少工具封裝一個總體框架 btn form animate 沒有組件庫以前都是這麼操做 都組裝到kj這個庫 後來繼續演變 sea.js 第三方庫
// kj.btn.js
(function(window){
if(!window.kj){
window.kj = {};
}
window.kj.Btn = { //封裝了btn組件
getVal:function(){
console.log('val')
},
setVal:function(str){
console.log('setval')
}
}
})(window || {})
//動畫組件
//kj.animate.js
(function(window){
if(!window.kj){
window.kj = {};
}
window.kj.animate = {};
})(window || {})
//form組件
//kj.form.js
(function(window){
if(!window.kj){
window.kj = {};
}
window.kj.form = {};
})(window || {})