JavaScript menambahkan elemen ke array
var colors= ["red","blue"];
colors.push("yellow");
Friendly Hawk
var colors= ["red","blue"];
colors.push("yellow");
array = ["hello"]
array.push("world");
console.log(array);
//output =>
["hello", "world"]
array.push(element)
var fruits = ["222", "vvvv", "eee", "eeee"];
fruits.push("Kiwi");
array = ["hello"]
array.push("world");
// Add to the end of array
let colors = ["white","blue"];
colors.push("red");
// ['white','blue','red']
// Add to the beggining of array
let colors = ["white","blue"];
colors.unshift("red");
// ['red','white','blue']
// Adding with spread operator
let colors = ["white","blue"];
colors = [...colors, "red"];
// ['white','blue','red']