Skip to content

Commit

Permalink
Merge pull request #390 from Heniker/patch-1
Browse files Browse the repository at this point in the history
Mention Object.groupBy()
  • Loading branch information
ODudek committed Apr 2, 2024
2 parents 412f0c1 + d17ebb5 commit ab3870a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,10 @@ Group items by key.
var grouped = ['one', 'two', 'three'].reduce((r, v, i, a, k = v.length) => ((r[k] || (r[k] = [])).push(v), r), {})
console.log(grouped)
// output: {3: ["one", "two"], 5: ["three"]}

// Native
Object.groupBy(['one', 'two', 'three'], ({length}) => length)
// output: {3: ["one", "two"], 5: ["three"]}
```

```js
Expand All @@ -1335,6 +1339,10 @@ Group items by key.
var grouped = [1.3, 2.1, 2.4].reduce((r, v, i, a, k = Math.floor(v)) => ((r[k] || (r[k] = [])).push(v), r), {})
console.log(grouped)
// output: {1: [1.3], 2: [2.1, 2.4]}

// Native
Object.groupBy([1.3, 2.1, 2.4], num => Math.floor(num))
// output: {1: [1.3], 2: [2.1, 2.4]}
```

#### Browser Support for `Array.prototype.reduce()`
Expand All @@ -1343,6 +1351,12 @@ Group items by key.
:-: | :-: | :-: | :-: | :-: | :-: |
✔ | ✔ | 3.0 ✔ | 9.0 ✔ | 10.5 ✔ | 4.0 ✔ |

#### Browser Support for `Object.groupBy()`

![Chrome][chrome-image] | ![Edge][edge-image] | ![Firefox][firefox-image] | ![IE][ie-image] | ![Opera][opera-image] | ![Safari][safari-image]
:-: | :-: | :-: | :-: | :-: | :-: |
117.0 ✔ | 117.0 ✔ | 119.0 ✔ | ✖ | 103.0 ✔ | 16.4 ✔ |

**[⬆ back to top](#quick-links)**

### _.includes
Expand Down

0 comments on commit ab3870a

Please sign in to comment.