Javascript Array methods

Javascript Array methods : join, shift, unshift, pop, push & reverse

Published 2021-07-16

Javascript Array Methods :

Join, Push, Shift, Unshift, Pop & Reverse

let colors = ["Red", "Green", "Blue"];

console.log(colors.join()) // "Red,Green,Blue"
console.log(colors.join(" - ")); // "Red - Green - Blue"

colors.push("Orange")
console.log(colors); // ["Red", "Green", "Blue", "Orange"]

colors.unshift("Teal")
console.log(colors); //["Teal", "Red", "Green", "Blue", "Orange"]

colors.shift()
console.log(colors); //["Red", "Green", "Blue", "Orange"]

colors.pop()
console.log(colors); //["Red", "Green", "Blue"]

colors.reverse()
console.log(colors); // ["Blue", "Green", "Red"]

Related Tutorials :