扫码一下
查看教程更方便
underscore.js 有许多易于使用的方法,使得迭代数组变得非常的方便。
underscore.js 提供了各种方法来迭代数组,如下所示
序号 | 方法 | 语法 |
---|---|---|
1 | first | _.first(array, [n]) |
2 | _.initial(array, [n]) | |
3 | _.last(array, [n]) | |
4 | rest | _.rest(array, [index]) |
5 | indexof | _.indexof(array, value, [issorted]) |
6 | lastindexof | _.lastindexof(array, value, [fromindex]) |
7 | sortedindex | _.sortedindex(array, value, [iteratee], [context]) |
8 | findindex | _.findindex(array, predicate, [context]) |
9 | findlastindex | _.findlastindex(array, predicate, [context]) |
underscore.js 有许多易于使用的方法,有助于处理数组。
underscore.js 提供了各种方法来处理数组,如下所示
序号 | 方法 | 语法 |
---|---|---|
1 | flatten | _.flatten(array, [shallow]) |
2 | _.without(array, *values) | |
3 | _.union(*arrays) | |
4 | intersection | _.intersection(*arrays) |
5 | _.difference(array, *others) | |
6 | uniq | _.uniq(array, [issorted], [iteratee]) |
7 | zip | _.zip(*arrays) |
8 | unzip | _.unzip(array) |
9 | object | _.object(list, [values]) |
10 | chunk | _.chunk(array, length) |
11 | range | _.range([start], stop, [step]) |