How to append an item into a JavaScript array?


To append an item to a JavaScript array, use the push() method.

Example

You can try to run the following code to append an item:

Live Demo

<html>
   <body>
      <script>
         var arr = ["marketing", "technical", "finance", "sales"];
         arr.push("HR");
         document.write(arr);
      </script>
   </body>
</html>

Output

marketing,technical,finance,sales,HR

Updated on: 13-Jan-2020

171 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements