Adding an element to the beginning of an array-
To add an element to the beginning of an array, you use the unshift()
method:
let seas = ['Black Sea', 'Caribbean Sea', 'North Sea', 'Baltic Sea'];
seas.unshift('Red Sea');
console.log(seas);
Adding an element to the beginning of an array-
To add an element to the beginning of an array, you use the unshift()
method:
let seas = ['Black Sea', 'Caribbean Sea', 'North Sea', 'Baltic Sea'];
seas.unshift('Red Sea');
console.log(seas);