Array Functions
1._first ([], N), _last ([], N), _initial ([], N)
_.first ([], N): takes the first n elements into an array to return, no N, and defaults back to the initial option (non-array)
_.first ([' A ', ' B ', ' C '])//n, take the first element
"a"
_.first ([' A ', ' B ', ' C '],1)//plus n, take an array of the first n elements
["a"]
_.first ([' A ', ' B ', ' C '],2)
["A", "B"]
_.last ([], N): After taking an array of n elements to return, no N, the default is to return the last option (non-array);
_initial ([], N): Takes out an array that does not contain the last item;
2._.rest ([], N): Returns an array from N, N: default = 1, which does not contain the first item
_.rest ([' A ', ' B ', ' C ', ' d '],2)
[' C ', ' d ']
_.rest ([' A ', ' B ', ' C ', ' d '])
[' B ', ' C ', ' d ']
3._.compact ([]): Remove false value in array (null,undefined,nan,0, ')
_.compact ([0, 1, False, 2, ', 3]);
= = [1, 2, 3]
4._.flatten ([], level): Converts multiple, multidimensional arrays into an array, levels control hierarchy
All flattening
_.flatten ([1, [2], [3, [[4]]]);
= = [1, 2, 3, 4];
Flatten only the first dimensional array
_.flatten ([1, [2], [3, [[4]]]], true);
= = [1, 2, 3, [[4]]];
5. _. Union ([],[],[],...): Set
_.intersection ([],[],[],...) : Intersection
_.diffrence ([],[],[],...) : Difference Set
_.without ([],arg1,arg2): Difference set exclusion
_.uniq ([]): Array de-weight
6._.zip ([],[],[]), _unzip ([],[],[])
_.zip ([' Moe ', ' Larry ', ' Curly '], [+, +], [True, False, false]);
= = [["Moe", +, True], ["Larry", +, false], ["Curly", "false]]
_.unzip ([["Moe", +, True], ["Larry", "Max," false], ["Curly", []]);
= = [' Moe ', ' Larry ', ' Curly '], [[+, +], [True, False, false]]
7._.object ([],[]) array variable object JSON
_.object ([' Moe ', ' Larry ', ' Curly '], [+, +]);
= = {moe:30, larry:40, curly:50} _.object ([' Moe ', ' +], ['
Larry ', ' +], [' Curly ', ']]);
= = {moe:30, larry:40, curly:50}
8._.range (start:0,stop,step); Creates an array of step for start to stop
_.range (ten);
= = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
_.range (1, one);
= = [1, 2, 3, 4, 5, 6, 7, 8, 9, ten]
_.range (0,, 5);
= = [0, 5, ten, +,
0, -10,-1] _.range;
= = [0,-1,-2, -3, -4, -5,-6,-7,-8,-9]
_.range (0);
= []