node.js - How to get a collection of values ​​in a dictionary structure?
我想大声告诉你
我想大声告诉你 2017-05-16 13:21:43
0
3
838
> a = {"1":[1,2,3], "2":[2,3,4], "3":[3,4,5]}
{ '1': [ 1, 2, 3 ],
  '2': [ 2, 3, 4 ],
  '3': [ 3, 4, 5 ] }
> Object.keys(a)
[ '1', '2', '3' ]
>

Excuse me, is there a way to get the value set [[1,2,3],[2,3,4],[3,4,5]]?

我想大声告诉你
我想大声告诉你

reply all(3)
滿天的星座
Object.keys(a).map(k => a[k])
我想大声告诉你

I usually use this kindunderscore

npm install underscore --save
var _ = require('underscore');
var a = {"1":[1,2,3], "2":[2,3,4], "3":[3,4,5]};
var values = _.values(a);
console.log(values);
小葫芦

First of all, the dictionary is unordered, so the obtained set is also unordered. It is the default order of the browser
You can use for in

var arr = [];
var cont = 0;
for(var i in a){
    for(var j=0; j<a[i].length;j++){
        arr[cont].push(a[i][j])
    }
    cont++;
}
console.log(arr)

There will definitely be no problem with compatibility like this

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template