Top 10 Javascript Array Methods🔥 -- Decoded.

Top 10 Javascript Array Methods🔥 -- Decoded.

javascript array methods explanation with examples.

Ten Different Array Methods:

___.push()

  • Adds one or more elements to the end of an array, and returns the new length of the array.
  • It's directly opposite to the pop method.

PUSH Method (1).png

___.pop()

  • Removes the last element from an array and returns that element.
  • Opposite to the pop method.

POP Method.png

___.shift()

  • Removes the first element from an array and returns that element.
  • Opposite to unshift method.

SHIfT Method.png

___.unshift()

  • Adds one or more elements to the front of an array, and returns the new length of the array.
  • Opposite to shift method.

UNSHIFT Method.png


Tip to remember:

  • Push & unshift Adds an element.
  • Pop & shift removes an element.

___.at()

  • Returns the array item at the given index. Accepts negative integers, which count back from the last item.

at Method.png

___.reverse()

  • Reverses the order of the elements of an array in place. (First becomes the last, last becomes first.)

REVERSE Method.png

___.includes()

  • Determines whether the calling array contains a value, returning true or false as appropriate.

INCLUDES Method.png

___.indexOf()

  • Returns the first (least) index at which a given element can be found in the calling array.
  • Used to locate values in an array.

IndexOf Method.png

___.slice()

  • It returns selected elements in an array, as a new array.
  • Syntax: array.slice(start, end)
  • It includes start value and excludes end value.

SLICE Method.png

___.concat()

  • Returns a new array that is the calling array joined with another array or value.

CONCAT Method.png

Thank you for Reading🙏🏻

For more useful content follow me on Twitter