一、基本格式
1 ;(function二、常用工具函式(undefined) ,//
加7 sub: function(n1,n2),//
減8 mul: function(n1,n2),//
乘9 div: function(n1,n2) //除10
}1112//
最後將外掛程式物件暴露給全域性物件
13 _global = (function()());
1415
//判斷是否存在載入器 存在就使用載入器 不存在就使用全域性物件
16if (typeof module !== "undefined" &&module.exports) else
if (typeof define === "function" &&define.amd) ); //
amd 載入
20 } else
23 }());
1、物件合併
1view codefunction
extend(o,n,override) 6}
7return
o;8 }
2、自定義模版引擎
1view codefunction
templateengine(html, data) ))(.*)?/g,
4 code = 'var r=;\n',
5 cursor = 0;
6var
match;
7var add = function
(line, js)
12while (match =re.exec(html))
16 add(html.substr(cursor, html.length -cursor));
17 code += 'return r.join("");';
18return
19 }
js常用工具函式總結
目錄 1 序列化時間 獲取當前序列化後的時間 dateformat 2 獲取當前日期前或指定時間,前一定範圍的時間 getassigntime 3 判斷是否是1366解析度 is1366screen 4 獲取echarts中x軸資料 getxlist 5 函式防抖 debounce 6 函式節流 t...
js 常用工具方法
1 cookie 操作 setcookie about 設定cookie 預設乙個月失效 function setcookie name,value getcookie about 獲取cookie function getcookie name else delcookie about 刪除coo...
js常用工具方法
slice substring substr 都有擷取字串的作用 1.substring substring 方法返回乙個索引和另乙個索引之間的字串 注意 方法返回乙個索引和另乙個索引之間的字串,語法如下 str.substring indexstart,indexend 下面有六點需要注意 sub...