Skip to content

Instantly share code, notes, and snippets.

@AlfieDarko
Last active August 13, 2018 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlfieDarko/12002d4ae7560ecd599d8de9a2b88853 to your computer and use it in GitHub Desktop.
Save AlfieDarko/12002d4ae7560ecd599d8de9a2b88853 to your computer and use it in GitHub Desktop.
reverse_mutation.js
let first6Months = ["Jan", "Feb", "March", "April", "May", "June"]
console.log(first6Months)
// Expected output: [ "June", "May", "April", "March", "Feb", "Jan" ]
let first6MonthsClone
first6MonthsClone = first6Months.reverse()
console.log(first6Months)
// Expected output: ["Jan", "Feb", "March", "April", "May", "June"]
let first6MonthsClone2
first6MonthsClone2 = first6Months.reverse().pop()
console.log(first6MonthsClone2)
// Expected output: "Jan"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment