Skip to content

How to Append an Item to Array in JavaScript

Advertisement

Question – How to Append an Item to Array in JavaScript. How do I append any element to end of the existing Array in JavaScript? How to push element to array in JavaScript?

This tutorial uses javascript push() function to insert or append a new element to end of the Array.

JavaScript – Append Element to Array

The following example creates an initial array with two elements (as “black”,”blue”). After that use javascript push() function to append new element (“white”) to the array.

Output:

[ 'black', 'blue', 'white' ]

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top