xxxxxxxxxx
// Add Element in array:
int[] terms = new int[200];
for (int run = 0; run < 400; run++)
{
terms[run] = value;
}
xxxxxxxxxx
const arr = [1, 2, 3, 4];
arr.push(5);
console.log(arr); // [1, 2, 3, 4, 5]
// another way
let arr = [1, 2, 3, 4];
arr = [arr, 5];
console.log(arr); // [1, 2, 3, 4, 5]
xxxxxxxxxx
// Add to the start of an array
Array.unshift(element);
// Add to the end of an array
Array.push(element);
// Add to a specified location
Array.splice(start_position, 0, new_element );
// Add with concat method without mutating original array
let newArray = [].concat(Array, element);
xxxxxxxxxx
let dailyActivities = ['eat', 'sleep'];
// add an element at the end
dailyActivities.push('exercise');
console.log(dailyActivities); // ['eat', 'sleep', 'exercise']
xxxxxxxxxx
addItems = items => {
this.setState({
emp: [
this.state.emp,
items
]
})
}
xxxxxxxxxx
$b=array("product"=>"$product","quantity"=>$quantity);
array_push($_SESSION['cart'],$b); // Items added to cart
xxxxxxxxxx
const arr = ['First item', 'Second item', 'Third item'];
arr.push('Fourth item');
console.log(arr); // ['First item', 'Second item', 'Third item', 'Fourth item']
xxxxxxxxxx
addItem = item => {
this.setState({
emp: [
this.state.emp,
item
]
})
}