lodash 提取前N个元素 take
_.take(array, [n=1])
从数组的起始元素开始提取 N 个元素。
<!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>提取 前N 个元素</title>
</head>
<body>
<script src="https://cdn.bootcss.com/lodash.js/4.17.10/lodash.min.js"></script>
<script type="text/javascript">
var arr = _.take([1, 2, 3], 2);;
console.log(arr);
//[1, 2]
</script>
</body>
</html>
作者:孟繁贵 Email:meng010387@126.com 期待共同进步!