-
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
[47장, 48장] 에러 처리, 모듈 #47
Comments
Merged
Q. 아래 빈칸들에 들어갈 값들을 작성해주세요 모듈 성립 조건
모듈의 재사용성애플리케이션과 완전히 분리되어 개별적으로 존재하는 모듈은 재사용이 불가능하다. 하지만 다음의 방법들을 이용해 재사용이 가능하다.
퀴즈 정답
스코프, export, import
|
Q. 다음 코드를 실행했을 때 출력 결과를 작성하시오. const foo = () => {
console.log("foo");
};
const bar = () => {
foo();
throw Error("foo에서 발생한 에러");
};
const baz = () => {
bar();
console.log("baz");
};
try {
baz();
} catch (err) {
console.error(err);
} finally {
console.log("finally는 생략 가능");
}
console.log("다들 고생하셨습니다!"); 퀴즈 정답foo |
Q. 프로그램이 강제 종료되지 않고 계속해서 코드를 실행시킬 수 있도록 수정해 주세요. foo(); // ReferenceError: foo is not defined // DOM에 button 요소가 존재하는 경우
const $button = document.querySelector('button'); // null
$button.classList.add('disabled'); 퀴즈 정답
try {
foo();
} catch(error) {
console.error(error);
}
const $button = document.querySelector('button');
$button?.classList.add('disabled'); |
Q. 아래와 같은 모듈이 있습니다. app 안에서 good_bye를 정상적으로 출력하는 방법을 알려주세요. <!DOCTYPE html>
<html>
<body>
<script type="module" src="app.js"/>
</body>
</html> //app.js
console.log(good_bye); // good_bye is not defined //good.js
const good_bye = "다들 고생많으셨습니다!";
console.log(good_bye); //다들 고생많으셨습니다! 퀴즈 정답good_bye를 export해주고 app.js에서 import하게 되면 정상출력됩니다. 😀 ```js //good.js export const good_bye = "다들 고생많으셨습니다!"; console.log(good_bye); //다들 고생많으셨습니다! ``` ```js //app.js import {good_bye} from './good.js console.log(good_bye); // good_bye is not defined ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
데브코스 4기 프롱이들 모던 JS Deep Dive 책 뿌수기😎
아래 템플릿을 복사해서 1개이상 퀴즈를 만들어주세요. 객관식, 주관식, 단답형 모두 상관없습니다!
The text was updated successfully, but these errors were encountered: