This tutorial is about array’s methods which will cover all the differences between them. Also, it will show when and how we should be using it
lets start with this array for this tutorial:
- First one - Pop() is an array method to remove the last element of the array. The method Syntax is pop( ). Output : [ 'Will', 'Bell', 'Anas' ]
- Second one - Push() is an array method to add new element at the end of the array. The method Syntax is Push( ). Output : [ 'Will', 'Bell', 'Anas', 'Adam', 'Zac' ]
- Third one - Unshift() is an array method to add new element at the first of the array. The method Syntax is Unshift( ). Output : [ 'Matt', 'Will', 'Bell', 'Anas', 'Adam' ]
- Last one - Shift() is an array method to remove the first element of the array. The method Syntax is Shift( ). Output : [ 'Bell', 'Anas', 'Adam' ]
ADDITIONAL RESOURCES:
pop()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/poppush()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pushunshift()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshiftshift()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
Top comments (0)