Skip to content

Instantly share code, notes, and snippets.

@emailjohnthomascaballero
Last active May 12, 2024 16:02
Show Gist options
  • Save emailjohnthomascaballero/100dfe7f016f98244e8f12b27a01c51a to your computer and use it in GitHub Desktop.
Save emailjohnthomascaballero/100dfe7f016f98244e8f12b27a01c51a to your computer and use it in GitHub Desktop.
// Remove Duplicate in Array:
[...new Set(arr)];
// Removes the first element from an array
arr.shift();
// Removes the last element fron an array
arr.pop();
// Adds value to the array
arr.unshift("John");
// Ascending Order Numbers in Array:
arr.sort((a, b) => b - a)
// Extracts or Slice the array (starts index 0 then stop in index 2)
arr.slice(0, 2)
// Check if what type. (String, boolean etc.)
typeof array.join(",");
// Output First and Last Value of Array:
const [firstItem, ...rest] = array;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment