Skip to content

Instantly share code, notes, and snippets.

@batazo
Created July 3, 2022 18:27
Show Gist options
  • Select an option

  • Save batazo/7d02d0bb26e33652471acb486fb0f0ad to your computer and use it in GitHub Desktop.

Select an option

Save batazo/7d02d0bb26e33652471acb486fb0f0ad to your computer and use it in GitHub Desktop.
AT METHOD FOR INDEX
const fruits = ['apples', 'oranges', 'pears'];
console.log(fruits[fruits.length - 1]); // pears
console.log(fruits.at(0)); // apples
console.log(fruits.at(-1)); // pears
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment