élément JS Array Ajouter
array.push(element)
Common Mynah
array.push(element)
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]
//original array
String[] rgb = new String[] {"red", "green"};
//new array with one more length
String[] rgb2 = new String[rgb.length + 1];
//copy the old in the new array
System.arraycopy(rgb, 0, rgb2, 0, rgb.length);
//add element to new array
rgb2[rgb.length] = "blue";
//optional: set old array to new array
rgb = rgb2;
// Add Element in array:
int[] terms = new int[200];
for (int run = 0; run < 400; run++)
{
terms[run] = value;
}
//testing to show how it works, javascript
$b=array("product"=>"$product","quantity"=>$quantity);
array_push($_SESSION['cart'],$b); // Items added to cart