Checkpoints 09 TIL

πŸ’β€β™€οΈ 였늘 μ•Œκ²Œλœ 사싀

  • 객체에 μƒˆλ‘œμš΄ 값을 μ„€μ •ν•΄ μ£Όλ©΄ ν˜„μž¬ μ°Έμ‘°ν•˜κ³  있던 μ£Όμ†Œκ°’μ€ 제거되고 λ‹€λ₯Έ reference type을 κ°€λ¦¬ν‚€κ²Œ λœλ‹€.

3번 - After the following code runs, what will be the value of x.foo?
πŸ‘‰πŸ» x.foo === 3

var x = { foo: 3 };
var y = x;
y = 2;

4번 - After the following code runs, what will be the value of myArray? πŸ‘‰πŸ» myArray === [2, 3, 4, 5]

var myArray = [2, 3, 4, 5];
var ourArray = myArray;
ourArray = [];

5번 - After the following code runs, what will be the value of myArray?
πŸ‘‰πŸ» myArray === [2, 3, 4, 5]

var myArray = [2, 3, 25, 5];
var ourArray = myArray;
ourArray[2] = 25;
ourArray = undefined;

7번 - After the following code runs, what will be the value of myArray?
πŸ‘‰πŸ» myArray === [2, 3, 4, 5]

var myArray = [2, 3, 4, 5];
function doStuff(arr) {
  arr = [];
}

doStuff(myArray);

8번 - After the following code runs, what will be the value of player.score?
πŸ‘‰πŸ» player.score === 2

var player = { score: 3 };
function doStuff(obj) {
  obj.score = 2;
  obj = undefined;
}

doStuff(player);

9번 - After the following code runs, what will be the value of player?
πŸ‘‰πŸ» player === undefined

var player = { score: 3 };

function doStuff(obj) {
  obj = {};
}

player = doStuff(player);

Written by@Heaeun
μ½”λ“œλ¦¬λ·°, TDD, ν•¨κ»˜ 자라기λ₯Ό 지ν–₯ν•˜λŠ” ν”„λ‘ νŠΈμ—”λ“œ κ°œλ°œμžμž…λ‹ˆλ‹€

GitHub