from a dropdown I'm selecting an array from a javascript object:
$("#selector").change(function() {
let array = [];
Object.values(group[$("#selector").val()]).forEach(x => array.push(x));
console.log(`Group: ${$("#selector").val()}, Array: ${array}`);
});
against an array such as:
let group = {
LocationA: [
{
name: "A",
length: 11,
width: 9,
height: 9
},
{
name: "B",
length: 26,
width: 6,
height: 20
},
{
name: "C",
length: 16,
width: 12,
height: 14
}
],
locationB: [{
name: "S-10662",
length: 32,
width: 18,
height: 12
}...
But the array outputs as a list of [object Object], not an array. I'm having difficulty copying a value (which is an array) into an array. I've searched for such an example, I cannot find one here.
arraywith anobject. Below is a good working solution, but I would recommend reading up on the difference to help you in the future. medium.com/@zac_heisey/objects-vs-arrays-42601ff79421