JavaScript Array Methods Cheat Sheet

Top popular JavaScript array methods.
concat()
['😉', '👊'].concat('😩')

// Output: (3) ["😉", "👊", "😩"]
join()
['👨‍🦳', '👩‍🦳'].join('💘')

// Output: "👨‍🦳💘👩‍🦳"
slice()
["😉", "👊", "😩"].slice(2)

// Output: ["😩"]
indexOf()
["😜", "👍", "🥶"].indexOf('👍')

// Output: 1
lastIndexOf()
["😜", "👍", "👍"].lastIndexOf('👍')

// Output: 2
reverse()
["😜", "👍", "🥶"].reverse()

// Output: (3) ["🥶", "👍", "😜"]
sort()
["👨", "👴", "👦"].sort()

// Output: (3) ["👦", "👨", "👴"]
shift()
["👦", "👨", "👴"].shift()

// Output: (2) ["👨", "👴"]
unshift()
["👦", "👨", "👴"].unshift('👩');

// Output: (4) ["👩", "👦", "👨", "👴"]
pop()
["👦", "👨", "👴"].pop();

// Output: (2) ["👦", "👨"]
push()
["👦", "👨", "👴"].push('🔥');

// Output: (4) ["👦", "👨", "👴", "🔥"]
filter()
["👦", "👨", "👴"].filter(person => person == '👨')

// Output: ["👨"]
includes()
["👦", "👨", "👴"].includes('👦')

// Output: true
Hope this will help you to mess with array.
You can suggest if I missed any thing. Also share suggestion for any other cheat sheet.

Happy.Code()

38

This website collects cookies to deliver better user experience

JavaScript Array Methods Cheat Sheet