-
-
Save skymins04/8ad596fe26ab2715d3c2da0617d23c4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = { | |
p1: 'hello', | |
p2: 'world', | |
}; | |
function changeVar(x: any) { | |
x.p1 = 'blah blah'; | |
x = {x: 1, y: 2}; // 함수 외부의 변수 a에는 아무런 영향을 미치지 않는다. | |
} | |
changeVar(a); | |
console.log(a); | |
/* | |
* output: | |
* { | |
* p1: 'blah blah', | |
* p2: 'world', | |
* } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment