> 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]]?
Object.keys(a).map(k => a[k])
I usually use this kindunderscore
underscore
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 browserYou 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
I usually use this kind
underscore
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
There will definitely be no problem with compatibility like this