Member-only story

JavaScript Array Methods Cheat Sheet: Your Go-To Guide for Everyday Usage

Vinodh Thangavel
3 min readAug 16, 2024

--

Mastering array methods in JavaScript can significantly enhance your coding efficiency and make your code cleaner and more readable. Here’s a handy cheat sheet of the most commonly used JavaScript array methods, arranged in the order of how often they’re typically used in day-to-day development.

push

  • Description: Adds one or more elements to the end of an array.
  • Usage: arr.push(element1,element2)
  • Example:
const fruits =['apple','banana']
fruits.push('orange') // ['apple','banana','orange']

pop

  • Description: Removes the last element from an array and returns it.
  • Usage: arr.pop()
  • Example:
const fruits =['apple','banana']
fruits.pop() // ['apple','banana'], returns the poped element 'orange'

shift

  • Description: Removes the first element from an array and returns it.
  • Usage: arr.shift()
  • Example:
const fruits =['apple','banana','orange']
fruits.shift() // ['banana','orange'], returns 'apple'

unshift

  • Description: Adds one or more elements to the begining of an array.
  • Usage: arr.unshift(element1,element2)
  • Example:

--

--

Vinodh Thangavel
Vinodh Thangavel

Written by Vinodh Thangavel

Passionate lifelong learner, coding enthusiast, and dedicated mentor. My journey in tech is driven by curiosity, creativity, and a love for sharing knowledge.

No responses yet