Skip to content

Instantly share code, notes, and snippets.

@yeonwooz
Created September 12, 2021 06:19
Show Gist options
  • Save yeonwooz/15d1f59e0d75cb9ec945d9194409b816 to your computer and use it in GitHub Desktop.
Save yeonwooz/15d1f59e0d75cb9ec945d9194409b816 to your computer and use it in GitHub Desktop.
mutableCloining
const addition = (param) => {
console.log(param) // []
const copiedParam = param
console.log('param', param, 'copiedParam', copiedParam) // param [] copiedParam []
param.push(11111)
copiedParam.push(22222)
console.log('param', param, 'copiedParam', copiedParam) // param [11111, 22222] copiedParam [11111, 22222]
return {param: param, copiedParam:copiedParam} // {param: [11111, 22222], copiedParam: [11111, 22222]}
}
const a = []
addition(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment