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.
In this example, we use push()
method to add object
at the end of array
.
xxxxxxxxxx
1
const object = { id: 1, value: 'a' };
2
3
const array = [];
4
5
array.push(object); // adds object at the end of array
6
7
console.log(JSON.stringify(array));