push operation in array using node.js


Overview

push method in arrays is used to insert an element in the end of the array.

Code


													
//Name of the file : array-push.js
arr = ['a','e','i','o'];
console.log(arr);
arr.push('u');
console.log(arr);	
													
												

Run

  • Now run the snippet using the following command :
    													
    >node array-push.js
    [ 'a', 'e', 'i', 'o' ]
    [ 'a', 'e', 'i', 'o', 'u' ]