Javascript In-Built Object Array – Methods

Array Methods:

  1. unshift() : Adds elements to the beginning of an array and returns the new length of the array.

Example:

var array1 = [1, 2, 3];

console.log(array1.unshift(4, 5));

output: 5

console.log(array1);

output: [4, 5, 1, 2, 3]

2. toString(): Converts array to string.

Example:

var array1 = [1, 2, 'a', '1a'];

console.log(array1.toString());

output: 1,2,a,1a