JavaScript Adding Elements to Array

If we want to add an item to an array in JavaScript, we can use the push() function.

Below is an example of how to use it.

// Creating var myArr = ["AA", "BB", "CC", "DD"]; //Adding 2 items myArr.push("EE", "FFı"); //Printing for (var i = 0; i < myArr.length; i++) { console.log(myArr[i]); }


You May Interest

What is Difference Between Call and Apply Methods in Javascript ?

What is Event Capturing in Javascript ?

What is setInterval Function in Javascript ?

JavaScript How To Find The Average Of 10 Numbers Using A While Lo ...

What are Deferred Scripts in Javascript ?