├── Cheatsheet.png
├── README.md
├── LICENSE
└── index.js
/Cheatsheet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ayushgptaa/Javascript-Array-cheatsheet/HEAD/Cheatsheet.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Javascript Array Cheatsheet👾
3 |
4 |
5 | 
6 |
7 |
10 |
11 |
12 |
13 | ## Important 🚨
14 |
15 | There is no way this is perfect or include all the methods. I'll try to fix/add more methods.For Now I have added only that methods that I knew about. Thanks for sparing your time and dropping by. Drop a star if this helped you ✨ and share with someone who could use this. Have a great day 🦄 .
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 ayush gupta
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /******************STATIC PROPERTIES*******************/
2 |
3 | Array.from('🍎🍌🍇'); // Creates an Array from a String, output: ["🍎", "🍌", "🍇"] //
4 |
5 | Array.isArray(['🍎', '🍌', '🍇']); // check for an array, output : true //
6 |
7 | Array.of('🍎', '🍌', '🍇'); // creates a new Array with provided elements output:["🍎", "🍌", "🍇"] //
8 |
9 | /******************INSTANCE PROPERTIES*******************/
10 |
11 | ['🍎', '🍌'].concat(['🍇', '🥭']); // Joins Two arrays, Output : ["🍎", "🍌", "🍇", "🥭"] //
12 |
13 | ['🍎', '🍌', '🍇', '🥭'].copyWithin(2, 0); //copy first 2 array elements to last 2, output: ["🍎", "🍌", "🍎","🍌"] //
14 |
15 | ['🍎', '🍌', '🍇'].filter(emoji => emoji === '🍎'); // Returns the array that matches our test output : ["🍎"] //
16 |
17 | ['🍎','🍌','🍇','🍒'].fill('🍑',2,3) // fill all the array elements with "🍑", output ['🍎','🍑','🍑','🍒']
18 |
19 | ['🍎', '🍌', '🍇'].find(emoji => emoji === '🍎'); // element in the array that has a value of "🍎", output : "🍎" //
20 |
21 | ['🍎', '🍌', '🍇'].indexOf('🍌'); // get the index of 🍌, output: 1 //
22 |
23 | ['🍎', '🍌', '🍇'].findIndex(emoji => emoji === '🍌'); // returns the index of the first element that satisfies the provided testing function. 🍌, output: 1 //
24 |
25 | ['🍎', '🍌', '🍇'].forEach(emoji => console.log(emoji)); // executes a provided function once for each array element, output :🍎🍌🍇 //
26 |
27 | ['🍎', '🍌', '🍇'].map(emoji => emoji + '🍒'); // Creates a new array by replacing with the return of a function for each array element, output: [🍎🍒, 🍌🍒 , 🍇🍒]
28 |
29 | ['🍎', '🍌', '🍇'].every(emoji => emoji === '🍎'); // Check if every element in the array has a value 🍎, Output : false //
30 |
31 | ['🍎', '🍌', '🍇'].some(emoji => emoji === '🍎'); // Check if atleast one element in the array has a value 🍎, Output : true //
32 |
33 | ['🍎', '🍌', '🍇'].includes('🥭'); // Check if the fruit array contains "🥭", output : false //
34 |
35 | ['🍎', '🍌', '🍇'].join(' + '); // Joins all elements of an array into a string, output : "🍎 + 🍌 + 🍇"//
36 |
37 | ['🍎', '🍌', '🍇'].pop(); // Removes and return the last element of an array, output: "🍇" //
38 |
39 | ['🍎', '🍌', '🍇'].push('🍒'); // Adds new elements to the end of an array and returns length, output: 4 //
40 |
41 | ['🍎', '🍌', '🍇'].reverse(); // Reverses the order of the elements in an array, output: ["🍇", "🍌", "🍎"] //
42 |
43 | ['🍎', '🍌', '🍇'].splice(1, 2); // Adds/Removes elements output: (removed array) ["🍌", "🍇"] (new array) ["🍎"] //
44 |
45 | ['🍎', '🍌', '🍇'].slice(1, 2); // Selects a part of an array, and returns the new array, output: ["🍌"] //
46 |
47 | ['🍎', '🍌', '🍇'].toString(); // Converts an array to a string, and returns the result, output:"🍎,🍌,🍇" //
48 |
49 | ['🍎', '🍌', '🍇'].shift(); // Removes the first element of an array, and returns that element, output: "🍎" //
50 |
51 | ['🍎', '🍌', '🍇'].unshift('🍐'); // Adds new elements to the beginning and returns the new length, output: 4 //
52 |
53 | ['🍎', '🍌', '🍇'].reduce((acc, cur) => acc + cur, '🍒'); //Reduce the values of an array to a single value, output: "🍒🍎🍌🍇"//
54 |
--------------------------------------------------------------------------------