JavaScript Quiz β‘ push() & shift() array methods

Let's break it down π₯
shift() removes the first element and returns the removed element.
push() adds the elements at the end of the array and returns the new length of the array
const roles = ["DevOps", "Front-End", "Back-End", "Designer"];
π The current array length is 4.
roles.shift() Removing DevOps element from the array
π Now, array length becomes 3 because one element has been removed with the shift method.
roles.push() is adding the deleted DevOps element at the end of the array.
π After pushing "DevOps" back to the end of the array, the new length of the array will return to the last push method.
roles.push() At the end length, 4 will get pushed as an element at the end of the array.
So, the output will become:
['Front-End', 'Back-End', 'Designer', 'DevOps', 4]




