push item to array js code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: pushing to an array
array = ["hello"]
array.push("world");
console.log(array);
//output =>
["hello", "world"]
Example 3: js array push
const arr = ["foo", "bar"];
arr.push('baz'); // 3
arr; // ["foo", "bar", "baz"]