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>框架

相关文章
相关标签/搜索