Underscore.js學習

underscore.js是一個JS框架,在原生JavaScript基礎上提供了不少有用的工具API。css

underscore官網 http://underscorejs.org/
官網中文翻譯 http://www.css88.com/doc/underscore/。html

直接上代碼,我是直接引用js,官網有node初始化版本的。node

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/underscore.js"></script>
<script>
$(document).ready(function () {
var arr = [1,2,4,5,4];
//_下劃線是underscore的一個對象
//遍歷 each
_.each(arr,function(val){
alert(val);
});
//map
_.map(arr,function(val){jquery

});
//last,first
console.log(_.last(arr));
console.log(_.first(arr));
});
</script>
</head>
<body>
</body>
</html>框架

相關文章
相關標籤/搜索