EN
JavaScript - push object into array
3
points
In this article, we would like to show you how to push an object into an array in JavaScript.
Practical example
In this example, we use push() method to add object at the end of array.
// ONLINE-RUNNER:browser;
const object = { id: 1, value: 'a' };
const array = [];
array.push(object); // adds object at the end of array
console.log(JSON.stringify(array));