lodash 集合处理方法 map和filter区别
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>lodash 集合处理方法 map和filter区别</title>
</head>
<body>
<script src="https://cdn.bootcss.com/lodash.js/4.17.10/lodash.min.js"></script>
<script type="text/javascript">
var users = [{
'user': 'barney',
'age': 36,
'active': true
},
{
'user': 'fred',
'age': 40,
'active': false
}
];
//输出 ["barney", "fred"]
console.log(_.map(users, 'user'))
// 输出[{ 'user': 'barney','age': 36,'active': true},{'user': 'fred','age': 40,'active': false}]
console.log(_.filter(users, 'user'))
</script>
</body>
</html>
作者:孟繁贵 Email:meng010387@126.com 期待共同进步!