javaScript Приложение элемент к массиву
var colors= ["red","blue"];
colors.push("yellow");
Friendly Hawk
var colors= ["red","blue"];
colors.push("yellow");
array.push(element)
// initialize array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
// append new value to the array
arr.push("Hola");
console.log(arr);
Run code snippet
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);
let items = [1, 2, 3]
items.push(4); // items = [1, 2, 3, 4]
<DOCTYPE html>
<html>
<body>
</html>