arr append js code example
Example 1: javascript array add
// example:
let yourArray = [1, 2, 3];
yourArray.push(4); // yourArray = [1, 2, 3, 4]
// syntax:
// <array-name>.push(<value-to-add>);
Example 2: js add element to array
var fruits = [ "Orange", "Apple", "Mango"];
fruits.push("Banana");
Example 3: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]