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