[Vuejs]-Push object into array without key in javascript

2👍

It’s hard to tell what you’re wanting, but I expect you don’t want to be using an array here at all? You just want a single object that contains all of your key-value pairs?

e.g. something like this:

const data = { id: 1234 };

let myId = data['id'];
var key = myId;
var myobj = {};
myobj[key] = {
  data: "testdata"
};

console.log(myobj);

// You can then add more data
myobj[2345] = {
  data: "more test data"
};

console.log(myobj);

// Example Property Access
console.log(myobj[2345])

1👍

Try this

newArr.push(...myobj);

Leave a comment