_. Range () is mainly used to obtain the range. Parameter description: (param1): Maximum range, (param1, param2): starting and ending range, (param1, param2, param3): starting and ending range, positive number is range span, -1 indicates the negative interval span.
_. Range (10);=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _. Range (1, 11);=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] _. Range (0, 30, 5);=> [0, 5, 10, 15, 20, 25] _. Range (0,-10,-1);=> [0,-1,-2,-3,-4,-5,-6,-7,-8,-9] _. Range (0);=> []
_. Each (list, function (C, I) {}) is mainly used to traverse each element for corresponding processing operations. Parameter description: list indicates the specific traversal array, function (C, I) processes the specific traversal, C indicates the specific traversal object parameter, and I indicates the specific index.
_. Each ([1, 2, 3], Alert );=> Alerts each numberInTurn... _. Each ({one:1, two: 2, three: 3}, Alert );=> Alerts each number valueInTurn...
_. Filer (list, function (c) {}) is mainly used to filter data based on conditions. Parameter description: list indicates the specific traversal array, and function (c) indicates the specific filtering operation. You need to return specific data.
VaREvens = _. Filter ([1, 2, 3, 4, 5, 6],Function(Num ){ReturnNum % 2 = 0;});=> [2, 4, 6]
_. Map (list, function (c) {}) is mainly used to perform operations based on elements. Parameter description: list is an array for specific traversal, and function (c) is the corresponding operation for specific execution. You need to return specific data.
_. Map ([1, 2, 3],Function(Num ){ReturnNum * 3;});=> [3, 6, 9] _. Map ({one:1, two: 2, three: 3 },Function(Num, key ){ReturnNum * 3;});=> [3, 6, 9]
_. Reduce (list, function (C, M) {var d M. push (d) return m}, []), mainly used to convert the format of the List elements, and generate a new result and return it. Parameter description: list is an array for specific traversal, function (c) is the data assembly operation executed, and new data results must be returned.
VaRSum = _. Reduce ([1, 2, 3],Function(Memo, num ){ReturnMemo + num;}, 0);=> 6
_. Find (list, function (c) {}) is mainly used to find matching objects in the corresponding data according to the conditions. Parameter description: list is an array for specific traversal, and function (c) is a condition rule for specific search.
VaREven = _. Find ([1, 2, 3, 4, 5, 6],Function(Num ){ReturnNum % 2 = 0;});=> 2
_. Some (list, function (c) {}) is mainly used to find whether a data exists in the array. Parameter description: list is an array for specific traversal, function (c) is a condition, and true or false is returned.
_. Some ([Null, 0, 'yes ',False]);=>True
_. Groupby (list, Param) is mainly used to group data sets based on grouping fields. Parameter description: list is an array to be traversed, And Param is a grouping field or grouping method. You can use single quotation marks to include the data in a specific grouping.
_. Groupby ([1.3, 2.1, 2.4],Function(Num ){ReturnMath. Floor (Num );});=> {1: [1.3], 2: [2.1, 2.4]} _. Groupby (['One', 'two', 'three '], 'length');==>{ 3: ["one", "two"], 5: ["three"]}
_. Sortby (list, function (c) {}) is mainly used to sort arrays. Parameter description: list is an array for specific traversal, and function (c) is a parameter for specific sorting. The default value is from small to large.
_. Sortby ([1, 2, 3, 4, 5, 6],Function(Num ){ReturnMath. Sin (Num );});=> [5, 4, 6, 3, 1, 2]
_. Indexby (list, Param) is mainly used to index data. Parameter description: list is an array to be traversed, And Param is an index field or method.
VaRStooges = [{Name: 'moe', age: 40}, {Name: 'Larry ', Age: 50}, {Name: 'curly', age: 60}]; _. Indexby (stooges,'Age');=>{"40": {Name: 'moe', age: 40},"50": {Name: 'Larry ', Age: 50},"60": {Name: 'curly ', age: 60}}
_. Values (list) is mainly used to convert objects into arrays. Parameter description: List is a specific object.
_. Values ({one: 1, two: 2, three: 3});=> [1, 2, 3]