JS

JAVASCRIPT ADD ELEMENTS TO ARRAY

PUSH - ADD TO END OF ARRAY var thearray = ["First", "Second"]; thearray.push("Third"); ]   First, Second, Third console.table(thearray);

ARRAY PUSH

01

UNSHIFT - ADD TO START OF ARRAY var thearray = ["First", "Second"]; thearray.unshift("Third");    Third, First, Second console.table(thearray);

UNSHIFT ARRAY

02

ASSIGN TO END OF ARRAY var thearray = ["First", "Second"]; thearray[thearray.length] = "Third";    First, Second, Third console.table(thearray);

ARRAY ASSIGN

03

ARRAY CONCAT

04

CONCAT- JOIN 2 ARRAYS var arrayA = ["First", "Second"]; var arrayB = ["Third", "Forth"]; var combined = arrayA.concat(arrayB);    First, Second, Third, Forth console.table(combined);

SPLICE INSERT thearray = ["First", "Second", "Third"]; thearray.splice(1, 0, "INSERTED!");     First, INSERTED, Second, Third console.table(thearray); 

ARRAY SPLICE

05