Underscore.js 初探

一. 簡介
 
Underscore 這個單詞的意思是「下劃線」。
 
Underscore.js 是一個 JavaScript 工具庫,提供了一整套的輔助方法供你使用。
 
Think that ---- "If I sit down in fornt of a blank HTML page, 高產似母豬, what do I need?" ··· underscore.js is the answer.
 
她彌補了 jQuery 沒有實現的功能,同時又是  Backbone 必不可少的部分。
 

 
2、組織結構
 
在  Underscore 的官方文檔 裏,你能夠看到這個 JavaScript 庫給你提供了這些輔助方法:
 
1. 集合方法(用來操做迭代對象,好比 Array 或者 Objects)
 
2. 與操做數組相關的方法
 
3. 與操做函數相關的方法
 
4. 與操做對象相關的方法
 
5. 工具方法
 
6. 面向對象的編程風格
 
7. 鏈式編程
 
下面咱們就針對這個目錄結構,進行學習:)
 

 
3、準備
 
多餘的話就不說了,咱們把 underscore-min.js 這個文件 下載(右擊,點擊「另存爲」)下來。這個 underscore-min.js 是生產環境下的版本,被壓縮過,文件是最小的。我用的是 1.8.3 版本。
 
把 underscore-min.js 引入到 HTML 頁面,像這樣 ↓ 
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>Underscore's Study Notes</title>
</head>

<body> 
    
    <script type="text/javascript" src="underscore-min.js"></script>    

</body>

</html>
 
這是模板文件,學習的過程當中,具體的例子代碼能夠在這裏編寫。
 

 
4、開始
 
1. 集合方法(Collections)
 
2. 與操做數組相關的方法(Arrays)
 
3. 與操做函數相關的方法(Functions)
 
4. 與操做對象相關的方法(Objects)
 
5. 工具方法(Utility)
 
6. 面向對象的編程風格(OOP style)
 
7. 鏈式編程(Chaining)
 
(完)
相關文章
相關標籤/搜索