打赏

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>

 

posted @ 2018-06-21 17:20  孟繁贵  阅读(1809)  评论(0编辑  收藏  举报
TOP