js arr push code example
Example 1: push array javascript
let array = ["A", "B"];
let variable = "what you want to add";
array.push(variable);
console.log(array);
Example 2: js push array
array.push(element_to_push);
Example 3: push javascript
let fruit = ['apple', 'banana']
fruit.push('cherry')
console.log(fruit)
Example 4: how to append object in array javascript
var select =[2,5,8];
var filerdata=[];
for (var i = 0; i < select.length; i++) {
filerdata.push(this.state.data.find((record) => record.id == select[i]));
}
Example 5: push at first index typescript
var a = [23, 45, 12, 67];
a.unshift(34);
console.log(a);
Example 6: javascript array push
let items_in_backpack = ['food', 'water', 'flashlight', 'GPS'];
items_in_backpack.push('javascript array push knowledge');