Skip to content

Instantly share code, notes, and snippets.

@francoisgeorgy
Last active March 22, 2020 09:25
Show Gist options
  • Select an option

  • Save francoisgeorgy/c4f7ef58d71d87d95158d0aaf50e998e to your computer and use it in GitHub Desktop.

Select an option

Save francoisgeorgy/c4f7ef58d71d87d95158d0aaf50e998e to your computer and use it in GitHub Desktop.
reverse #array in javascript
let a = ["zero", "one", "two", "three"];
a.slice(0).reverse().map((o, i) => {
console.log(`${i}, ${o}`);
});
/* RESULT:
> let a = ["zero", "one", "two", "three"];
> a.slice(0).reverse().map((o, i) => { console.log(`${i}, ${o}`); });
0, three
1, two
2, one
3, zero
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment