ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## take + [link](./take "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L6654 "View in source.") + [npm](https://www.npmjs.com/package/lodash.take "See the npm package.") ``` _.take(array, [n=1]) ``` 从数组的起始元素开始提取 N 个元素。 ### 参数 1. array (Array) 需要处理的数组 2. [n=1] (number) 要提取的个数 ### 返回值 (Array) 返回提取的元素数组 ### 示例 ``` _.take([1, 2, 3]); // => [1] _.take([1, 2, 3], 2); // => [1, 2] _.take([1, 2, 3], 5); // => [1, 2, 3] _.take([1, 2, 3], 0); // => [] ```