1번 - After the following code runs, what will be the value of x?
var x = 2;
var y = x;
y = 3;
2
3
Not Sure
2번 - After the following code runs, what will be the value of x.foo?
var x = { foo: 3 };
var y = x;
y.foo = 2;
2
3
Not Sure
3번 - After the following code runs, what will be the value of x.foo?
var x = { foo: 3 };
var y = x;
y = 2;
2
3
undefined
Reference Error
4번 - After the following code runs, what will be the value of myArray?
var myArray = [2, 3, 4, 5];
var ourArray = myArray;
ourArray = [];
[ ]
[2, 3, 4, 5]
undefined
3번재쭐은 새로운 배열을 ourArray에 할당/ myArray변화 없음
5번 - After the following code runs, what will be the value of myArray?
var myArray = [2, 3, 4, 5];
var ourArray = myArray;
ourArray[2] = 25;
ourArray = undefined;
[ ]
[2, 3, 4, 5]
undefined
[2, 3, 25, 4, 5]
[2, 3, 25, 5]
6번 - After the following code runs, what will be the value of myArray?
var myArray = [2, 3, 4, 5];
function doStuff(arr) {
arr[2] = 25;
}
doStuff(myArray);
[ ]
[2, 3, 4, 5]
undefined
[2, 3, 25, 4, 5]
[2, 3, 25, 5]
7번 - After the following code runs, what will be the value of myArray?
var myArray = [2, 3, 4, 5];
function doStuff(arr) {
arr = [ ];
}
doStuff(myArray);
[ ]
[2, 3, 4, 5]
undefined
[2, 3, 25, 4, 5]
[2, 3, 25, 5]
arr이라는 내부변수에 새로운 배열을 할당
myArr가 전달된게 아니라 주소가 전달되어서 주소의 내용이 변경되지 않으면 myArray는 동일하다.
8번 - After the following code runs, what will be the value of player.score?
var player = { score: 3 };
function doStuff(obj) {
obj.score = 2;
obj = undefined;
}
doStuff(player);
2
3
undefined
Not sure
같은곳을 바라보는곳의 score 변경
obj = undefined;를 할당(player를 바라보다가 새로운곳으로)
9번 - After the following code runs, what will be the value of player?
var player = { score: 3 };
function doStuff(obj) {
obj = {};
}
player = doStuff(player);
{ score: 3 }
{ }
undefined
Not Sure
doStuff함수가 player를 넣어서 실행하게될경우 빈객체로 만들어버림
player는 undefined 가 들어감 (리턴값이 없어서)
10번 - After the following code runs, what will be the value of example?
var obj = {
inner: { x: 10 }
};
var example = obj.inner;
obj.inner = undefined;
{ inner: { x: 10 } }
{ x: 10 }
10
undefined
Not Sure
obj.inner를 값을 변경해줘도 example는 변경안됨
'코드스테이츠(Immersive) > 체크포인트' 카테고리의 다른 글
Checkpoints 12 - Chatterbox Server (0) | 2019.08.14 |
---|---|
Checkpoints 10 - Order of Execution (0) | 2019.07.28 |
Checkpoints 08 - JavaScript Callbacks (0) | 2019.07.27 |
Checkpoint 7 - Function Binding (0) | 2019.07.27 |
Checkpoints 04 - JS Prototypes(Object.create) (0) | 2019.07.24 |