singlr value push to array code example
Example 1: js push
let arr = [9, 4, 3, 18]
arr.push(30)
console.log(arr) // [9, 4, 3, 18, 30]
Example 2: push javascript
/*The push() method adds elements to the end of an array, and unshift() adds
elements to the beginning.*/
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];
romanNumerals.push(twentyThree);
// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']
romanNumerals.unshift('XIX', 'XX');
// now equals ['XIX', 'XX', 'XXI', 'XXII']