回答編集履歴
1
追記
test
CHANGED
@@ -41,3 +41,49 @@
|
|
41
41
|
);
|
42
42
|
|
43
43
|
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
ついでにfirefoxじゃないと動かない書き方で。
|
52
|
+
|
53
|
+
```javascript
|
54
|
+
|
55
|
+
(function(arr){
|
56
|
+
|
57
|
+
return [
|
58
|
+
|
59
|
+
[x, arr.reduce(function(sum, [k, v]){
|
60
|
+
|
61
|
+
return sum += k==x ? v : 0;
|
62
|
+
|
63
|
+
}, 0)]
|
64
|
+
|
65
|
+
for
|
66
|
+
|
67
|
+
(x of new Set(
|
68
|
+
|
69
|
+
[ k for each ([k, ] in arr ) ]
|
70
|
+
|
71
|
+
))
|
72
|
+
|
73
|
+
]
|
74
|
+
|
75
|
+
})([
|
76
|
+
|
77
|
+
["a",10],
|
78
|
+
|
79
|
+
["b",20],
|
80
|
+
|
81
|
+
["c",30],
|
82
|
+
|
83
|
+
["a",40],
|
84
|
+
|
85
|
+
["a",50]
|
86
|
+
|
87
|
+
]);
|
88
|
+
|
89
|
+
```
|