From 286c99afada6ae8d7ed4ffbb2543f51ff0b8aed9 Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:15:47 +0900 Subject: [PATCH 1/8] =?UTF-8?q?add=20:=20ch23-1=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chapter23/ch23-\353\254\270\354\240\234.md" | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" index 7050109..765ac91 100644 --- "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" +++ "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" @@ -1,10 +1,19 @@ # Chapter23 실행 컨텍스트 + ## 📌문제1 -### 문제 작성 + +### true,false를 고르시오. + ``` +1. 자바스크립트 엔진은 소스코드를 2개의 과정, “소스코드의 평가" 와 “소스코드의 실행” 과정으로 나누어 처리한다. +2. 렉시컬 환경은 식별자와 식별자에 바인딩된 값, 그리고 상위 스코프에대한 참조를 기록하는 자료구조다. +3. 렉시컬 환경은 EnvironmentRecord, OuterLexicalEnvironmentReference로 구성된다. ``` + ### 답안 작성 + ``` + ```
From 36593fa7005bac53a40462d1b4ada649c2dd3294 Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:15:55 +0900 Subject: [PATCH 2/8] =?UTF-8?q?add=20:=20ch23-1=20=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chapter23/ch23-\355\225\264\354\204\244.md" | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" index 5ab604b..81569f3 100644 --- "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" +++ "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" @@ -1,10 +1,23 @@ # Chapter23 실행 컨텍스트 + ## 📌문제1 -### 문제 작성 + +### true,false를 고르시오. + ``` +1. 자바스크립트 엔진은 소스코드를 2개의 과정, “소스코드의 평가" 와 “소스코드의 실행” 과정으로 나누어 처리한다. +2. 렉시컬 환경은 식별자와 식별자에 바인딩된 값, 그리고 상위 스코프에대한 참조를 기록하는 자료구조다. +3. 렉시컬 환경은 EnvironmentRecord, OuterLexicalEnvironmentReference로 구성된다. ``` -### 정답 및 해설 + +### 답안 작성 + ``` +1.true + a.평가과정에선 실행 컨텍스트를 생성하고 변수,함수 등의 선언문만 실행컨텍스트가 관리하는 스코프(렉시컬 환경의 레코드)에 등록한다. + b.실행과정에선 선언문 이외의 문을 실행시킨다. +2.true : p.366 +3.true : p.367 ```
From ab329a172cf32a90e7894e25cf4af40b1b9bb66c Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:18:45 +0900 Subject: [PATCH 3/8] =?UTF-8?q?add=20:=20ch23-2=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chapter23/ch23-\353\254\270\354\240\234.md" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" index 765ac91..f1c6fe2 100644 --- "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" +++ "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" @@ -17,3 +17,19 @@ ```
+ +## 📌문제2 + +### 전역 환경 레코드를 구성하는 컴포넌트2가지를 작성하고 각각에서 관리되는 값이 무엇인지 서술하시오. + +``` + +``` + +### 답안 작성 + +``` + +``` + +
From 6b79f80744a3e0048cd4c7f17b36d092d7a06bde Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:18:54 +0900 Subject: [PATCH 4/8] =?UTF-8?q?add=20:=20ch23-2=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ch23-\355\225\264\354\204\244.md" | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" index 81569f3..aea2db3 100644 --- "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" +++ "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" @@ -13,11 +13,26 @@ ### 답안 작성 ``` -1.true - a.평가과정에선 실행 컨텍스트를 생성하고 변수,함수 등의 선언문만 실행컨텍스트가 관리하는 스코프(렉시컬 환경의 레코드)에 등록한다. - b.실행과정에선 선언문 이외의 문을 실행시킨다. -2.true : p.366 -3.true : p.367 + +``` + +
+ +## 📌문제2 + +### 전역 환경 레코드를 구성하는 컴포넌트2가지를 작성하고 각각에서 관리되는 값이 무엇인지 서술하시오. + +``` + +``` + +### 답안 작성 + +``` +1. 객체 환경레코드(Object Environment Record) + a. var키워드로 선언한 전역 변수와 함수 선언문으로 정의한 전역 함수,빌트인 전역 프로퍼티, 빌트인 전역 함수, 표준 빌트인 객체 +2. 선언적 환경 레코드(Declarative Environment Record) + a. let,const 키워드로 선언한 전역 변수 ```
From fc1f06a9168607b8cc01904cec2bb823f5130c03 Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:22:18 +0900 Subject: [PATCH 5/8] =?UTF-8?q?add=20:=20ch23-3=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ch23-\353\254\270\354\240\234.md" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" index f1c6fe2..5b09dfd 100644 --- "a/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" +++ "b/Chapter21~30/Chapter23/ch23-\353\254\270\354\240\234.md" @@ -33,3 +33,26 @@ ```
+ +## 📌문제3 + +### 다음 코드가 실행될때의 렉시컬환경의 변화에대해서 작성하시오. + +```js +let x = 1; + +if (true) { + let x = 10; + console.log(x); // 10 +} + +console.log(x); // 1 +``` + +### 답안 작성 + +``` + +``` + +
From c46d255a6f3b89f75d26de903f8fcf521b72a96f Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:22:24 +0900 Subject: [PATCH 6/8] =?UTF-8?q?add=20:=20ch23-3=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ch23-\355\225\264\354\204\244.md" | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" index aea2db3..3e6415a 100644 --- "a/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" +++ "b/Chapter21~30/Chapter23/ch23-\355\225\264\354\204\244.md" @@ -29,10 +29,30 @@ ### 답안 작성 ``` -1. 객체 환경레코드(Object Environment Record) - a. var키워드로 선언한 전역 변수와 함수 선언문으로 정의한 전역 함수,빌트인 전역 프로퍼티, 빌트인 전역 함수, 표준 빌트인 객체 -2. 선언적 환경 레코드(Declarative Environment Record) - a. let,const 키워드로 선언한 전역 변수 + +``` + +
+ +## 📌문제3 + +### 다음 코드가 실행될때의 렉시컬환경의 변화에대해서 작성하시오. + +```js +let x = 1; + +if (true) { + let x = 10; + console.log(x); // 10 +} + +console.log(x); // 1 +``` + +### 답안 작성 + +``` +-> 코드가 실행되는과정에서 전역 실행컨텍스트의 렉시컬환경은 전역 렉시컬 환경을 가리키다가, if이 실행되는과정에서 if문의 코드블록의 렉시컬 환경을 생성한후 이를 전역 렉시컬 환경을 대체한다. 이때 전역 렉시컬환경은 사라지지않고 코드블록 렉시컬환경의 외부 렉시컬환경에의해 참조되고, if문이 종료되면 다시 전역 렉시컬 환경으로 대체된다. ```
From 79ece2fdabaf11e0ae6990f5cb6452a5b1a24ad7 Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:28:07 +0900 Subject: [PATCH 7/8] =?UTF-8?q?add=20:=20ch24-1,2,3=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ch24-\355\225\264\354\204\244.md" | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git "a/Chapter21~30/Chapter24/ch24-\355\225\264\354\204\244.md" "b/Chapter21~30/Chapter24/ch24-\355\225\264\354\204\244.md" index f969798..8270c34 100644 --- "a/Chapter21~30/Chapter24/ch24-\355\225\264\354\204\244.md" +++ "b/Chapter21~30/Chapter24/ch24-\355\225\264\354\204\244.md" @@ -1,10 +1,79 @@ # Chapter24 클로저 + ## 📌문제1 -### 문제 작성 + +### 아래코드의 결과가 다음과같은 이유에대해서 설명하시오. + +```js +const x = 1; + +function outerFunc() { + const x = 10; + innerFunc(); +} + +function innerFunc() { + console.log(x); +} + +outerFunc(); // 1 +``` + +### 답안 작성 + +``` +자바스크립트는 렉시컬 스코프를 따르는 언어이기 때문에, 함수의 호출 위치가아닌, 선언된 위치에의해 상위 스코프를 결정하기 때문에, 10이 아닌 1이 호출결과로 나타난다. +``` + +
+ +## 📌문제2 + +### 아래코드중 클로저를 찾으시오. + +```js +const x = 1; + +function outer() { + // 1 + const y = 10; + const inner = function () { + console.log(y); + }; // 2 + return inner; +} + +const innerFunc = outer(); +innerFunc(); ``` + +### 답안 작성 + ``` -### 정답 및 해설 +→ inner. + + outer함수의 중첩함수인 inner함수는 outer함수의 실행이 종료되고 outer함수의 실행 컨테스트가 실행컨텍스트의 스택에서 제거되었음에도 불구하고 outer함수의 지역변수인 y를 참조하게되기 때문이다. ``` + +
+ +## 📌문제3 + +### true or false 중 고르시오. + +``` +1.대부분의 모던 브라우저에서의 클로저란 상위스코프를 전체다 기억하는것을 의미한다. + +2.자유변수란 클로저에 의해 참조되고 있지않는 상태의 변수를 의미한다. +``` + +### 답안 작성 + +``` +1.false : 상위 스코프의 식별자중에서 기억해야할 식별자만을 기억한다. + +2.false : 참조되는 변수를 자유변수라하고, 클로저란 “자유변수에대해 닫혀있다”, “자유변수에 묶여있는 함수”라고 할 수 있다. + ```
From 07ec6b263165896fe9879208c8412b9cc0f16da3 Mon Sep 17 00:00:00 2001 From: gangpyono Date: Sun, 18 Sep 2022 20:28:16 +0900 Subject: [PATCH 8/8] =?UTF-8?q?add=20:=20ch24-1,2,3=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ch24-\353\254\270\354\240\234.md" | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git "a/Chapter21~30/Chapter24/ch24-\353\254\270\354\240\234.md" "b/Chapter21~30/Chapter24/ch24-\353\254\270\354\240\234.md" index 688e36f..d0d113a 100644 --- "a/Chapter21~30/Chapter24/ch24-\353\254\270\354\240\234.md" +++ "b/Chapter21~30/Chapter24/ch24-\353\254\270\354\240\234.md" @@ -1,10 +1,74 @@ # Chapter24 클로저 + ## 📌문제1 -### 문제 작성 + +### 아래코드의 결과가 다음과같은 이유에대해서 설명하시오. + +```js +const x = 1; + +function outerFunc() { + const x = 10; + innerFunc(); +} + +function innerFunc() { + console.log(x); +} + +outerFunc(); // 1 +``` + +### 답안 작성 + +``` + +``` + +
+ +## 📌문제2 + +### 아래코드중 클로저를 찾으시오. + +```js +const x = 1; + +function outer() { + // 1 + const y = 10; + const inner = function () { + console.log(y); + }; // 2 + return inner; +} + +const innerFunc = outer(); +innerFunc(); +``` + +### 답안 작성 + +``` + +``` + +
+ +## 📌문제3 + +### true or false 중 고르시오. + ``` +1.대부분의 모던 브라우저에서의 클로저란 상위스코프를 전체다 기억하는것을 의미한다. + +2.자유변수란 클로저에 의해 참조되고 있지않는 상태의 변수를 의미한다. ``` + ### 답안 작성 + ``` + ```