Object, synthesize a new array?

var obj = {

"1": [111, 222],
"2": [333],
"3": [444, 555]

};
var arr = [];
for (var i in obj) {

arr.push(...obj[i]);

}
console.log (arr);
or
var obj = {

"1": [111, 222],
"2": [333],
"3": [444, 555]

};
var arr = [];
for (var i in obj) {

for(var j in obj[i]){
    arr.push(obj[i][j]);
}    

}
console.log (arr);
or
var arr = [];
for (var i in obj) {

arr=arr.concat(obj[i]);

}
console.log (arr);
it would be easy to make reasonable use of the ES2015 feature.

var obj = {

"1": [111, 222],
"2": [333],
"3": [444, 555]

};
let arr = Object.values (obj). Reduce ((afort b) = > a.concat (b)); / / [111222333444555]

Dec.28,2021

actually, is not a problem. You can write it in your own notes , think about , and take notes

.
Menu