Methods on array:

We can apply few methods on array in order to remove or add any values. we can use pop(), push(), shift(), unshift().

// * methods on array
const countries = ["swiss", "UK", "france"];

// * Pushes the element to last
countries.push("Italy")

// * Unshift adds to begining of element
countries.unshift("Iceland")

// * Pop removes the last element
countries.pop();

// * shift removes the first element
countries.shift();

console.log(countries);

join() Method

The join() method also joins all array elements into a string. It behaves like this,

syntax:

variablename.join(' * ');
const countries = ["swiss", "UK", "france"];
console.log(countries.join(' * ');

Deleting Elements

Using delete may leave undefined holes in the array. You can delete an element using delete keyword,

syntax:

delete variableName;
const countries = ["swiss", "UK", "france"];
console.log(delete countries[0]);

Splice() Method

The splice() method can be used to add new items to an array. It has two parameters,

syntax:

splice(start, deleteCount, item1, item2, itemN)