Skip to content

Instantly share code, notes, and snippets.

@fkfk
Last active September 22, 2018 19:41
Show Gist options
  • Save fkfk/d7be7d0bc24aa90276a7e534251cbec1 to your computer and use it in GitHub Desktop.
Save fkfk/d7be7d0bc24aa90276a7e534251cbec1 to your computer and use it in GitHub Desktop.
Safari 12 Array.prototype.reverse bug
let fn = () => {
let array = [1, 2, 3, 4, 5]
console.log(array)
array.reverse()
}
fn() // => [1, 2, 3, 4, 5]
fn() // I expect to be `[1, 2, 3, 4, 5]`, but in the case of Safari 12 it will be `[5, 4, 3, 2, 1]`
let fn = (array) => {
console.log(array)
array.reverse()
}
fn([1, 2, 3, 4, 5]) // => [1, 2, 3, 4, 5]
fn([1, 2, 3, 4, 5]) // I expect to be `[1, 2, 3, 4, 5]`, but in the case of Safari 12 it will be `[5, 4, 3, 2, 1]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment