js add element to array first code example
Example 1: javascript add new array element to start of array
var colors = ["white","blue"];
colors.unshift("red");
Example 2: javascript append how first element
parentElement.prepend(newFirstChild)
Example 3: js add element to front of array
var numbers = ["2", "3", "4", "5"];
numbers.unshift("1");
Example 4: prepend to array javascript
var data = [ "X" ];
data.unshift( "A" );
data.unshift( "B", "C" );
console.log( data );
Example 5: how to make and add to an array in javascript
var arrayExample = [53,'Hello World!'];
console.log(arrayExample)
[53,'Hello World!']
arrayExample.push(true);
console.log(arrayExample);
[53,'Hello World!',true];
Example 6: javascript append how first element
var eElement;
var newFirstElement;
eElement.insertBefore(newFirstElement, eElement.firstChild);