Skip to content

Instantly share code, notes, and snippets.

@shsunmoonlee
Created December 24, 2018 15:15
Show Gist options
  • Select an option

  • Save shsunmoonlee/f9549226d17ea1fed72077ff2a96ea71 to your computer and use it in GitHub Desktop.

Select an option

Save shsunmoonlee/f9549226d17ea1fed72077ff2a96ea71 to your computer and use it in GitHub Desktop.
functionDoesntCopyMap
function functionDoesntCopyMap() {
let map = {1: 2, 2: 3}
let val = 3
function functionCopiesValue(map, val) {
map[1] --
val --
console.log("inner map, val", map, val)
}
console.log("======functionDoesntCopyMap")
functionCopiesValue(map, val)
console.log("outer map, val", map, val)
}
functionDoesntCopyMap()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment