1번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
function add (x, y) { return x + y; }
var result = add(x, f());
20
21
22
2번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
}
var result = x;
f();
10
11
12
3번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
var result = [x, f(), x];
[10, 11, 11]
[11, 11, 11]
[10, 11, 10]
[10, 10, 10]
리턴이 없을경우 [10, undefined, 11]
4번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
var obj = {
func: f,
g: f(),
h: x,
};
obj.func();
var result = obj.g;
10
11
12
13
함수의 실행여부, 순서 확인
5번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
f();
setTimeout(f, 1000);
f();
var result = x;
10
11
12
13
6번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
f();
setTimeout(f(), 1000);
f();
var result = x;
10
11
12
13
실행표시가 있어서 바로 실행
7번 - After the following code runs, what will be the value of result?
var x = 10;
function f () {
x = x + 1;
return x;
}
var result = f;
result = result();
function f () {...}
10
11
Throws an error
8번 - After the following code runs, what will be the value of result?
var x = 10;
var obj = {
y: x,
z: obj.y + 1
};
var result = obj.z;
10
11
Throws an error
호이스팅
'코드스테이츠(Immersive) > 체크포인트' 카테고리의 다른 글
Checkpoint 01, 03-JavaScript Scopes, Keyword 'this' (0) | 2019.08.25 |
---|---|
Checkpoints 12 - Chatterbox Server (0) | 2019.08.14 |
Checkpoints 09 - Value vs. Reference (0) | 2019.07.28 |
Checkpoints 08 - JavaScript Callbacks (0) | 2019.07.27 |
Checkpoint 7 - Function Binding (0) | 2019.07.27 |