Last active
April 29, 2023 22:10
-
-
Save kistaaa/2398d9954042d751019eed22100519fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is x really array? | |
Array.isArray(x) | |
// Add array y to the end of x | |
x.concat(y) | |
// Is y in x? | |
x.includes(y) | |
// Which index is y? | |
x.indexOf(y) | |
// Insert item at end | |
x.push(y) | |
// Insert item at index | |
x.splice(index, 0, y) | |
// Replace item at index | |
x.splice(index, 1, y) | |
// Remove last item | |
x.pop() | |
// Remove first item | |
x.shift() | |
// Remove items | |
x.slice(2) //first 2 items | |
x.slice(2, 4) // first 2 and 4 | |
// MAP - Edit everything | |
x.map(y => y * 2); | |
// Reverse order | |
x.reverse() | |
// Alphabetical order (strings) | |
x.sort() | |
// Convert to string | |
x.toString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment