4

How do I push some data into a certain place in an array?

I am trying the code below:

Keys[1].push({ Keys: "Test" });

But it doesn't seem to work as expected

mplungjan
  • 169,008
  • 28
  • 173
  • 236
user4058171
  • 213
  • 1
  • 4
  • 9

1 Answers1

3

The method you are looking for is splice

arrayObject.splice(index,0,{Keys:"Test"});

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice

Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100