Skip to content

Instantly share code, notes, and snippets.

@kistaaa
Last active April 29, 2023 22:10
Show Gist options
  • Save kistaaa/2398d9954042d751019eed22100519fb to your computer and use it in GitHub Desktop.
Save kistaaa/2398d9954042d751019eed22100519fb to your computer and use it in GitHub Desktop.
// 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