-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[18, 20장] 함수와 일급 객체, strict mode #12
Comments
Q 다음 문장이 옳은지 아닌지 O, X 로 판별해주세요!
퀴즈 정답
(1) O
(2) X (with 문은 사용시 성능과 가독성이 나빠지는 문제가 있습니다. 이러한 이유로 strict 모드에서 사용하면 에러가 발생합니다.) |
Q. 다음 코드를 실행했을 때의 결과로 옳은 것은?(function (a) {
'use strict';
a = 0;
A(); -(1)
new B(); -(2)
new C(); -(3)
function A() {
console.log(this);
}
function B() {
console.log(this);
}
var C = function () {
console.log(this);
}
console.log(arguments); -(4)
}(10));
퀴즈 정답정답 : 4번(1) 일반 함수로 호출하면 this에 undefined가 바인딩됨 (2) 생성자 함수로 호출하면 this에 B 생성자 함수가 생성할 인스턴스를 가리킴 (3) 함수 선언문과 함수 표현식의 호이스팅 방식의 차이 (4) strict mode에선 매개 변수에 전달된 인수를 재할당해도 arguments 객체에 반영되지 않음 |
Q. arguments 객체의 length 프로퍼티와 함수객체의 length 프로퍼티는 각각 무엇을 가리키는지 작성하고 밑의 코드의 실행값은 무엇일까요?function foo(a,b,c) {
return arguments.length;
}
console.log(foo(1,2,3,4,5,6)); // (1)
console.log(foo.length) // (2)
퀴즈 정답
arguments 객체의 length 프로퍼티 : 인자의 개수
함수 객체의 length 프로퍼티 : 매개변수의 개수 (1) 6 (2) 3 ※ 매개변수 vs (전달) 인자 |
Q. 다음 코드의 결과값을 작성해 주세요 function foo() {
x = 10;
}
foo();
console.log(x); // [1]
function foo() {
'use strict'
x = 10;
}
foo();
console.log(x); // [2]
function foo() {
x = 10;
'use strict'
}
foo();
console.log(x); // [3] 퀴즈 정답[1] - 10[2] - ReferenceError: x is not defined |
Q. 다음은 함수 객체 프로퍼티의 내용이다. 틀린 것을 고르시오.
퀴즈 정답
3번
함수 객체의 length 프로퍼티는 매개변수의 개수를 가리키고 arguments 객체의 length 프로퍼티는 인자의 개수를 가리킨다. // 함수 객체 length 프로퍼티
function add(x, y, z) {
return x + y + z;
}
console.log(add.length); // 3
// arguments 객체 length 프로퍼티
function multiply(x, y, z) {
console.log(arguments.length); // 2
return x * y;
}
multiply(1, 2); |
Q. 다음 코드의 주석을 완성해 주세요. const obj = { a: 1 };
console.log(obj.__proto__ === Object.prototype); // (1)
console.log(obj.hasOwnProperty('__proto__')); // (2)
console.log(obj.hasOwnProperty('a')); // (3) 퀴즈 정답
(1) true (2) false (3) true
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
데브코스 4기 프롱이들 모던 JS Deep Dive 책 뿌수기😎
아래 템플릿을 복사해서 2개이상 퀴즈를 만들어주세요. 객관식, 주관식, 단답형 모두 상관없습니다!
The text was updated successfully, but these errors were encountered: