Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- codewars
- Debug
- TypeScript
- IBM
- JDBC
- DB2
- react
- custom hook
- descendingOrder
- manifest.json
- TABLESPACE
- react hook
- type
- codewar
- useEffect
- java api
- isSquare
Archives
- Today
- Total
taesik
Count instance in object 본문
var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];
var countedNames = names.reduce(function (allNames, name) {
if (name in allNames) {
allNames[name]++;
}
else {
allNames[name] = 1;
}
return allNames;
}, {});
// countedNames is:
// { 'Alice': 2, 'Bob': 1, 'Tiff': 1, 'Bruce': 1 }'Concepts > TypeScript' 카테고리의 다른 글
| curring (0) | 2022.01.23 |
|---|---|
| increase 1 per 1second using closure function (0) | 2022.01.23 |
| closure 1 - return result of function /return function (0) | 2022.01.23 |
| Utility Type (0) | 2021.12.28 |