27
JavaScript Array Methods Cheat Sheet
Top popular JavaScript array methods.
['😉', '👊'].concat('😩')
// Output: (3) ["😉", "👊", "😩"]
['👨🦳', '👩🦳'].join('💘')
// Output: "👨🦳💘👩🦳"
["😉", "👊", "😩"].slice(2)
// Output: ["😩"]
["😜", "👍", "🥶"].indexOf('👍')
// Output: 1
["😜", "👍", "👍"].lastIndexOf('👍')
// Output: 2
["😜", "👍", "🥶"].reverse()
// Output: (3) ["🥶", "👍", "😜"]
["👨", "👴", "👦"].sort()
// Output: (3) ["👦", "👨", "👴"]
["👦", "👨", "👴"].shift()
// Output: (2) ["👨", "👴"]
["👦", "👨", "👴"].unshift('👩');
// Output: (4) ["👩", "👦", "👨", "👴"]
["👦", "👨", "👴"].pop();
// Output: (2) ["👦", "👨"]
["👦", "👨", "👴"].push('🔥');
// Output: (4) ["👦", "👨", "👴", "🔥"]
["👦", "👨", "👴"].filter(person => person == '👨')
// Output: ["👨"]
["👦", "👨", "👴"].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()
27