From aef9870f219f5806fb96d5c826d484d57e714014 Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:22:49 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.4=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EC=99=80=20=EC=83=81=EC=88=98=20=EC=B6=A9?= =?UTF-8?q?=EB=8F=8C=20=ED=95=B4=EA=B2=B0=20=EB=B0=8F=20=EB=B2=88=EC=97=AD?= =?UTF-8?q?=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/02-first-steps/04-variables/article.md | 99 ++------------------- 1 file changed, 9 insertions(+), 90 deletions(-) diff --git a/1-js/02-first-steps/04-variables/article.md b/1-js/02-first-steps/04-variables/article.md index 73d681680..8dc026708 100644 --- a/1-js/02-first-steps/04-variables/article.md +++ b/1-js/02-first-steps/04-variables/article.md @@ -24,11 +24,7 @@ let message; let message; *!* -<<<<<<< HEAD -message = 'Hello'; // 문자열을 저장합니다. -======= -message = 'Hello'; // store the string 'Hello' in the variable named message ->>>>>>> upstream/master +message = 'Hello'; // 문자열 'Hello'를 message라는 변수에 저장합니다. */!* ``` @@ -67,12 +63,8 @@ let age = 25; let message = 'Hello'; ``` -<<<<<<< HEAD -어떤 사람들은 이런 방식으로도 변수를 정의합니다. -======= -Some people also define multiple variables in this multiline style: +어떤 사람들은 다음과 같이 여러 줄에 걸쳐 변수를 정의하기도 합니다. ->>>>>>> upstream/master ```js no-beautify let user = 'John', age = 25, @@ -96,37 +88,23 @@ let user = 'John' *!*var*/!* message = 'Hello'; ``` -<<<<<<< HEAD `var`는 `let`과 *거의* 동일하게 동작합니다. `var`도 `let`처럼 변수를 선언하는 데 쓰이죠. 다만 `var`는 '오래된' 방식입니다. `let`과 `var`의 미묘한 차이점에 대해선 추후 에서 자세히 다루도록 하겠습니다. 지금 시점에선 이 차이점이 중요하지 않기 때문에 넘어가도록 합시다. -======= -The `var` keyword is *almost* the same as `let`. It also declares a variable but in a slightly different, "old-school" way. - -There are subtle differences between `let` and `var`, but they do not matter to us yet. We'll cover them in detail in the chapter . ->>>>>>> upstream/master ```` ## 현실 속의 비유 '상자' 안에 데이터를 저장하는데, 이 상자에는 특별한 이름표가 붙어 있다고 상상해 봅시다. 이렇게 하면 '변수'를 좀 더 쉽게 이해할 수 있습니다. -<<<<<<< HEAD 예를 들어, 변수 `message`는 `message`라는 이름표가 붙어있는 상자에 `"Hello!"`라는 값을 저장한 것이라고 생각할 수 있습니다. -======= -For instance, the variable `message` can be imagined as a box labelled `"message"` with the value `"Hello!"` in it: ->>>>>>> upstream/master ![](variable.svg) 상자 속엔 어떤 값이든지 넣을 수 있습니다. -<<<<<<< HEAD -원하는 만큼 값을 변경할 수도 있습니다. -======= -We can also change it as many times as we want: +다음과 같이 원하는 만큼 값을 변경할 수도 있습니다. ->>>>>>> upstream/master ```js run let message; @@ -172,21 +150,12 @@ let message = "That"; // SyntaxError: 'message' has already been declared 따라서 변수는 딱 한 번만 선언하고, 선언한 변수를 참조할 때는 `let` 없이 변수명만 사용해 참조해야 합니다. ```` -<<<<<<< HEAD ```smart header="함수형 언어" -[함수형(functional)](https://en.wikipedia.org/wiki/Functional_programming) 프로그래밍 언어는 변숫값 변경을 금지합니다. [스칼라(Scala)](http://www.scala-lang.org/)와 [얼랭(Erlang)](http://www.erlang.org/)은 대표적인 함수형 언어입니다. -======= -```smart header="Functional languages" -It's interesting to note that there exist so-called [pure functional](https://en.wikipedia.org/wiki/Purely_functional_programming) programming languages, such as [Haskell](https://en.wikipedia.org/wiki/Haskell), that forbid changing variable values. ->>>>>>> upstream/master +흥미롭게도, [하스켈(Haskell)](https://en.wikipedia.org/wiki/Haskell)과 같이 변숫값 변경을 금지하는, 이른바 [순수 함수형(pure functional)](https://en.wikipedia.org/wiki/Purely_functional_programming) 프로그래밍 언어도 있습니다. 이들 언어에서는 '상자 속에' 값이 일단 저장되면, 그 값을 영원히 유지합니다. 다른 값을 저장하고 싶다면 새로운 상자를 만들어야(새 변수를 선언해야)만 합니다. 이전 변수를 재사용할 수 없습니다. -<<<<<<< HEAD -처음 봤을 땐 좀 이상해 보일 수 있지만, 함수형 언어는 중대한 개발에 상당히 적합한 언어입니다. 이런 제약이 장점으로 작용하는 병렬 계산(parallel computation)과 같은 영역도 있죠. 당장은 사용할 계획이 없더라도 이런 언어를 공부하는 것은 시야를 넓히는 데 도움이 되므로, 학습을 권유 드립니다. -======= -Though it may seem a little odd at first sight, these languages are quite capable of serious development. More than that, there are areas like parallel computations where this limitation confers certain benefits. ->>>>>>> upstream/master +처음 봤을 땐 좀 이상해 보일 수 있지만, 함수형 언어는 중대한 개발에 상당히 적합한 언어입니다. 이런 제약이 장점으로 작용하는 병렬 계산(parallel computation)과 같은 영역도 있죠. ``` ## 변수 명명 규칙 @@ -203,11 +172,7 @@ let userName; let test123; ``` -<<<<<<< HEAD 여러 단어를 조합하여 변수명을 만들 땐 [카멜 표기법(camelCase)](https://en.wikipedia.org/wiki/CamelCase)이 흔히 사용됩니다. 카멜 표기법은 단어를 차례대로 나열하면서 첫 단어를 제외한 각 단어의 첫 글자를 대문자로 작성합니다. `myVeryLongName`같이 말이죠. -======= -When the name contains multiple words, [camelCase](https://en.wikipedia.org/wiki/CamelCase) is commonly used. That is: words go one after another, with each word except the first starting with a capital letter: `myVeryLongName`. ->>>>>>> upstream/master 달러 기호 `'$'` 와 밑줄 `'_'` 를 변수명에 사용할 수 있다는 점이 조금 특이하네요. 이 특수 기호는 일반 글자처럼 특별한 의미를 지니진 않습니다. @@ -228,32 +193,19 @@ let 1a; // 변수명은 숫자로 시작해선 안 됩니다. let my-name; // 하이픈 '-'은 변수명에 올 수 없습니다. ``` -<<<<<<< HEAD ```smart header="대·소문자 구별" -`apple`와 `AppLE`은 서로 다른 변수입니다. -``` - -````smart header="비 라틴계 언어도 변수명에 사용할 수 있지만 권장하진 않습니다." -키릴 문자, 심지어 상형문자도 변수명에 사용할 수 있습니다. 모든 언어를 변수명에 사용할 수 있죠. -======= -```smart header="Case matters" -Variables named `apple` and `APPLE` are two different variables. +`apple`와 `APPLE`은 서로 다른 변수입니다. ``` -````smart header="Non-Latin letters are allowed, but not recommended" -It is possible to use any language, including Cyrillic letters, Chinese logograms and so on, like this: ->>>>>>> upstream/master +````smart header="비 라틴계 문자도 변수명에 사용할 수 있지만 권장하진 않습니다." +키릴 문자나 한자를 비롯한 어떤 언어의 문자든 변수명에 사용할 수 있습니다. 다음과 같이 말이죠. ```js let имя = '...'; let 我 = '...'; ``` -<<<<<<< HEAD 위 코드에는 기술적인 에러가 없습니다. 변수명도 유효합니다. 하지만 영어를 변수명에 사용하는 것이 국제적인 관습이므로, 변수명은 영어를 사용해서 만들길 권유 드립니다. 다른 나라 사람이 스크립트를 볼 경우 등을 대비해 장기적인 안목을 가지고 코드를 작성합시다. -======= -Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it sometime. ->>>>>>> upstream/master ```` ````warn header="예약어" @@ -308,20 +260,12 @@ const myBirthday = '18.04.1982'; myBirthday = '01.01.2001'; // error, can't reassign the constant! ``` -<<<<<<< HEAD 변숫값이 절대 변경되지 않을 것이라 확신하면, 값이 변경되는 것을 방지하면서 다른 개발자들에게 이 변수는 상수라는 것을 알리기 위해 `const`를 사용해 변수를 선언하도록 합시다. -======= -When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and communicate that fact to everyone. ->>>>>>> upstream/master ### 대문자 상수 -<<<<<<< HEAD 기억하기 힘든 값을 변수에 할당해 별칭으로 사용하는 것은 널리 사용되는 관습입니다. -======= -There is a widespread practice to use constants as aliases for difficult-to-remember values that are known before execution. ->>>>>>> upstream/master 이런 상수는 대문자와 밑줄로 구성된 이름으로 명명합니다. @@ -346,29 +290,17 @@ alert(color); // #FF7F00 그렇다면 언제 일반적인 방식으로 상수를 명명하고, 언제 대문자를 사용해서 명명해야 하는 걸까요? 명확히 짚고 넘어갑시다. -<<<<<<< HEAD '상수'는 변수의 값이 절대 변하지 않음을 의미합니다. 그중에는 (빨간색을 나타내는 16진수 값처럼) 코드가 실행되기 전에 이미 그 값을 알고 있는 상수도 있고, 런타임 과정에서 *계산되지만* 최초 할당 이후 값이 변하지 않는 상수도 있습니다. -예시: -======= -Being a "constant" just means that a variable's value never changes. But some constants are known before execution (like a hexadecimal value for red) and some constants are *calculated* in run-time, during the execution, but do not change after their initial assignment. +예를 들면 다음과 같습니다. -For instance: - ->>>>>>> upstream/master ```js const pageLoadTime = /* 웹페이지를 로드하는데 걸린 시간 */; ``` -<<<<<<< HEAD `pageLoadTime`의 값은 페이지가 로드되기 전에는 정해지지 않기 때문에 일반적인 방식으로 변수명을 지었습니다. 하지만 이 값은 최초 할당 이후에 변경되지 않으므로 여전히 상수입니다. 정리하자면, 대문자 상수는 '하드 코딩한' 값의 별칭을 만들 때 사용하면 됩니다. -======= -The value of `pageLoadTime` is not known before the page load, so it's named normally. But it's still a constant because it doesn't change after the assignment. - -In other words, capital-named constants are only used as aliases for "hard-coded" values. ->>>>>>> upstream/master ## 바람직한 변수명 @@ -376,31 +308,18 @@ In other words, capital-named constants are only used as aliases for "hard-coded 변수명은 간결하고, 명확해야 합니다. 변수가 담고있는 것이 무엇인지 잘 설명할 수 있어야 하죠. -<<<<<<< HEAD 변수의 이름을 짓는 것은 프로그래밍에서 가장 중요하고 복잡한 기술 중 하나입니다. 변수명만 슬쩍 봐도 초보자가 코드를 작성했는지, 노련한 개발자가 작성했는지 알 수 있습니다. 실제 프로젝트에선 맨 처음부터 완전히 독립적인 코드를 작성하기보다 기존 코드의 틀을 변경하고 확장하는데 대부분의 시간을 보냅니다. 작성했던 코드를 얼마 후에 다시 봤을 때, 정보에 알맞은 이름이 적혀있으면 정보를 더 쉽게 찾을 수 있습니다. 다시 말해, 변수가 올바른 이름을 가졌을 때 말이죠. -======= -Variable naming is one of the most important and complex skills in programming. A glance at variable names can reveal which code was written by a beginner versus an experienced developer. - -In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names. ->>>>>>> upstream/master 그러므로 변수를 선언하기 전에 내가 지은 변수의 이름이 괜찮은지 숙고해 주시기 바랍니다. 아래는 변수 명명 시 참고하기 좋은 규칙입니다. -<<<<<<< HEAD - `userName` 이나 `shoppingCart`처럼 사람이 읽을 수 있는 이름을 사용하세요. - 무엇을 하고 있는지 명확히 알고 있지 않을 경우 외에는 줄임말이나 `a`, `b`, `c`와 같은 짧은 이름은 피하세요. - 최대한 서술적이고 간결하게 명명해 주세요. `data`와 `value`는 나쁜 이름의 예시입니다. 이런 이름은 아무것도 설명해주지 않습니다. 코드 문맥상 변수가 가리키는 데이터나 값이 아주 명확할 때에만 이런 이름을 사용합시다. - 자신만의 규칙이나 소속된 팀의 규칙을 따르세요. 만약 사이트 방문객을 'user'라고 부르기로 했다면, 이와 관련된 변수를 `currentVisitor`나 `newManInTown`이 아닌 `currentUser`나 `newUser`라는 이름으로 지어야 합니다. -======= -- Use human-readable names like `userName` or `shoppingCart`. -- Stay away from abbreviations or short names like `a`, `b`, and `c`, unless you know what you're doing. -- Make names maximally descriptive and concise. Examples of bad names are `data` and `value`. Such names say nothing. It's only okay to use them if the context of the code makes it exceptionally obvious which data or value the variable is referencing. -- Agree on terms within your team and in your mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`. ->>>>>>> upstream/master 간단해 보이나요? 그렇게 보이긴 합니다. 그러나 실전에서 서술적이고 간결한 변수명을 짓는 것은 간단하지 않습니다. 그럼, 화이팅! From 37d4889dbadc341584cc3da6f41d7d7343becc94 Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:23:48 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.5=20?= =?UTF-8?q?=EC=9E=90=EB=A3=8C=ED=98=95=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20=EB=B0=8F=20=EB=B2=88=EC=97=AD=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/02-first-steps/05-types/article.md | 120 ++++++------------------ 1 file changed, 27 insertions(+), 93 deletions(-) diff --git a/1-js/02-first-steps/05-types/article.md b/1-js/02-first-steps/05-types/article.md index fbcdad1b5..307c816c5 100644 --- a/1-js/02-first-steps/05-types/article.md +++ b/1-js/02-first-steps/05-types/article.md @@ -46,25 +46,15 @@ n = 12.345; alert( "숫자가 아님" / 2 ); // NaN, 문자열을 숫자로 나누면 오류가 발생합니다. ``` -<<<<<<< HEAD - `NaN`은 여간해선 바뀌지 않습니다. `NaN`에 어떤 추가 연산을 해도 결국 `NaN`이 반환됩니다. - - ```js run - alert( "숫자가 아님" / 2 + 5 ); // NaN - ``` - - 연산 과정 어디에선가 `NaN`이 반환되었다면, 이는 모든 결과에 영향을 미칩니다. -======= - `NaN` is sticky. Any further mathematical operation on `NaN` returns `NaN`: + `NaN`은 여간해선 바뀌지 않습니다. `NaN`에 어떤 추가 수학 연산을 해도 결국 `NaN`이 반환됩니다. ```js run alert( NaN + 1 ); // NaN alert( 3 * NaN ); // NaN - alert( "not a number" / 2 - 1 ); // NaN + alert( "숫자가 아님" / 2 - 1 ); // NaN ``` - So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result (there's only one exception to that: `NaN ** 0` is `1`). ->>>>>>> upstream/master + 연산 과정 어디에선가 `NaN`이 반환되었다면, 이는 모든 결과에 영향을 미칩니다. (단 하나의 예외는 `NaN ** 0`이 `1`이 된다는 점입니다.) ```smart header="수학 연산은 안전합니다." 자바스크립트에서 행해지는 수학 연산은 '안전'하다고 볼 수 있습니다. 0으로 나눈다거나 숫자가 아닌 문자열을 숫자로 취급하는 등의 이례적인 연산이 자바스크립트에선 가능합니다. @@ -78,26 +68,20 @@ n = 12.345; ## BigInt [#bigint-type] -<<<<<<< HEAD -내부 표현 방식 때문에 자바스크립트에선 (253-1)(`9007199254740991`) 보다 큰 값 혹은 -(253-1) 보다 작은 정수는 '숫자형'을 사용해 나타낼 수 없습니다. +내부 표현 방식 때문에 자바스크립트에선 (253-1)(`9007199254740991`) 보다 큰 정수 혹은 -(253-1) 보다 작은 정수는 '숫자형'을 사용해 나타낼 수 없습니다. -사실 대부분의 상황에서 이런 제약사항은 문제가 되지 않습니다. 그렇지만 암호 관련 작업같이 아주 큰 숫자가 필요한 상황이거나 아주 높은 정밀도로 작업을 해야 할 때는 이런 큰 숫자가 필요합니다. -======= -In JavaScript, the "number" type cannot safely represent integer values larger than (253-1) (that's `9007199254740991`), or less than -(253-1) for negatives. - -To be really precise, the "number" type can store larger integers (up to 1.7976931348623157 * 10308), but outside of the safe integer range ±(253-1) there'll be a precision error, because not all digits fit into the fixed 64-bit storage. So an "approximate" value may be stored. +정확히 말하면, '숫자형'은 더 큰 정수도 저장할 수 있습니다. 최대 1.7976931348623157 * 10308까지 저장할 수 있죠. 하지만 안전한 정수의 범위인 ±(253-1)를 벗어나면 정밀도 오류가 발생합니다. 모든 자릿수를 고정된 64비트 저장 공간에 담을 수 없기 때문입니다. 따라서 '근삿값'이 저장될 수 있습니다. -For example, these two numbers (right above the safe range) are the same: +예를 들어, 안전한 정수의 범위를 살짝 벗어나는 다음 두 숫자는 같은 값으로 취급합니다. ```js console.log(9007199254740991 + 1); // 9007199254740992 console.log(9007199254740991 + 2); // 9007199254740992 ``` -So to say, all odd integers greater than (253-1) can't be stored at all in the "number" type. +다시 말해, (253-1)보다 큰 모든 홀수 정수는 '숫자형'에 아예 저장할 수 없습니다. -For most purposes ±(253-1) range is quite enough, but sometimes we need the entire range of really big integers, e.g. for cryptography or microsecond-precision timestamps. ->>>>>>> upstream/master +사실 대부분의 상황에서 이런 제약사항은 문제가 되지 않습니다. 그렇지만 암호 관련 작업같이 아주 큰 숫자가 필요한 상황이거나 아주 높은 정밀도로 작업을 해야 할 때는 이런 큰 숫자가 필요합니다. `BigInt`형은 표준으로 채택된 지 얼마 안 된 자료형으로, 길이에 상관없이 정수를 나타낼 수 있습니다. @@ -110,15 +94,7 @@ const bigInt = 1234567890123456789012345678901234567890n; `BigInt`형 숫자는 자주 쓰이지 않기 때문에 여기서 자세히 다루지 않고 별도의 챕터, 에서 설명드리겠습니다. 아주 큰 숫자를 사용해야 하는 경우라면 해당 챕터를 참고해 주시기 바랍니다. -<<<<<<< HEAD -```smart header="호환성 이슈" -이 글이 작성된 시점엔 Firefox, Chrome, Edge, Safari에서만 `BigInt`를 지원합니다. IE에선 지원하지 않습니다. -``` - ## 문자형 -======= -## String ->>>>>>> upstream/master 자바스크립트에선 문자열(string)을 따옴표로 묶습니다. @@ -160,11 +136,7 @@ alert( "the result is ${1 + 2}" ); // the result is ${1 + 2} (큰따옴표는 ```smart header="*글자형*은 없습니다." 일부 언어는 글자 하나를 저장할 때 쓰이는 자료형, '글자(character)'형을 따로 지원합니다. C 언어와 Java의 `char`가 대표적인 예입니다. -<<<<<<< HEAD -자바스크립트는 글자형을 지원하지 않습니다. `문자형`만 있을 뿐입니다. 여기엔 글자가 하나 혹은 여러 개 들어갈 수 있습니다. -======= -In JavaScript, there is no such type. There's only one type: `string`. A string may consist of zero characters (be empty), one character or many of them. ->>>>>>> upstream/master +자바스크립트는 글자형을 지원하지 않습니다. `문자형`만 있을 뿐입니다. 여기엔 글자가 0개일 수도 있고(빈 문자열), 하나 혹은 여러 개일 수도 있습니다. ``` ## 불린형 @@ -245,22 +217,9 @@ alert(age); // "undefined" ## typeof 연산자 [#type-typeof] -<<<<<<< HEAD `typeof` 연산자는 인수의 자료형을 반환합니다. 자료형에 따라 처리 방식을 다르게 하고 싶거나 변수의 자료형을 빠르게 알아내고자 할 때 유용합니다. -`typeof` 연산자는 두 가지 형태의 문법을 지원합니다. - -1. 연산자: `typeof x` -2. 함수: `typeof(x)` - -괄호가 있든 없든 결과가 동일합니다. - `typeof x`를 호출하면 인수의 자료형을 나타내는 문자열을 반환합니다. -======= -The `typeof` operator returns the type of the operand. It's useful when we want to process values of different types differently or just want to do a quick check. - -A call to `typeof x` returns a string with the type name: ->>>>>>> upstream/master ```js typeof undefined // "undefined" @@ -290,64 +249,39 @@ typeof alert // "function" (3) 마지막 세 줄은 약간의 설명이 필요해 보이네요. -<<<<<<< HEAD 1. `Math`는 수학 연산을 제공하는 내장 객체이므로 `"object"`가 출력됩니다. `Math`에 대해선 챕터에서 학습하도록 하겠습니다. 내장 객체는 객체형이라는 것을 알려주기 위해 이런 예시를 작성해 보았습니다. 2. `typeof null`의 결과는 `"object"`입니다. `null`은 별도의 고유한 자료형을 가지는 특수 값으로 객체가 아니지만, 하위 호환성을 유지하기 위해 이런 오류를 수정하지 않고 남겨둔 상황입니다. 언어 자체의 오류이므로 `null`이 객체가 아님에 유의하시기 바랍니다. 3. `typeof`는 피연산자가 함수면 `"function"`을 반환합니다. 그러므로 `typeof alert`는 `"function"`을 출력해줍니다. 그런데 '함수'형은 따로 없습니다. 함수는 객체형에 속합니다. 이런 동작 방식이 형식적으론 잘못되긴 했지만, 아주 오래전에 만들어진 규칙이었기 때문에 하위 호환성 유지를 위해 남겨진 상태입니다. 한편, 실무에선 이런 특징이 매우 유용하게 사용되기도 합니다. -## 요약 -======= -1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter . Here, it serves just as an example of an object. -2. The result of `typeof null` is `"object"`. That's an officially recognized error in `typeof`, coming from very early days of JavaScript and kept for compatibility. Definitely, `null` is not an object. It is a special value with a separate type of its own. The behavior of `typeof` is wrong here. -3. The result of `typeof alert` is `"function"`, because `alert` is a function. We'll study functions in the next chapters where we'll also see that there's no special "function" type in JavaScript. Functions belong to the object type. But `typeof` treats them differently, returning `"function"`. That also comes from the early days of JavaScript. Technically, such behavior isn't correct, but can be convenient in practice. - -```smart header="The `typeof(x)` syntax" -You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`. +```smart header="`typeof(x)` 문법" +코드에서 `typeof(x)`라는 또 다른 문법을 보실 수도 있습니다. 이는 `typeof x`와 동일합니다. -To put it clear: `typeof` is an operator, not a function. The parentheses here aren't a part of `typeof`. It's the kind of parentheses used for mathematical grouping. +정확히 말하자면, `typeof`는 함수가 아니라 연산자입니다. 여기서 괄호는 `typeof`의 일부가 아닙니다. 수학에서 식을 묶을 때 쓰는 괄호와 같은 종류의 괄호입니다. -Usually, such parentheses contain a mathematical expression, such as `(2 + 2)`, but here they contain only one argument `(x)`. Syntactically, they allow to avoid a space between the `typeof` operator and its argument, and some people like it. +보통 이런 괄호 안에는 `(2 + 2)`처럼 수식이 들어가지만, 여기서는 `(x)`처럼 인수 하나만 들어갑니다. 문법적으로는 `typeof` 연산자와 인수 사이에 공백을 쓰지 않게 해주며, 이를 선호하는 사람들도 있습니다. -Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common. +`typeof x` 문법이 훨씬 더 일반적이지만, `typeof(x)`를 선호하는 사람들도 있습니다. ``` -## Summary ->>>>>>> upstream/master +## 요약 자바스크립트에는 여덟 가지 기본 자료형이 있습니다. -<<<<<<< HEAD -- `숫자형` -- 정수, 부동 소수점 숫자 등의 숫자를 나타낼 때 사용합니다. 정수의 한계는 ±253 입니다. -- `bigint` -- 길이 제약 없이 정수를 나타낼 수 있습니다. -- `문자형` -- 빈 문자열이나 글자들로 이뤄진 문자열을 나타낼 때 사용합니다. 단일 문자를 나타내는 별도의 자료형은 없습니다. -- `불린형` -- `true`, `false`를 나타낼 때 사용합니다. -- `null` -- `null` 값만을 위한 독립 자료형입니다. `null`은 알 수 없는 값을 나타냅니다. -- `undefined` -- `undefined` 값만을 위한 독립 자료형입니다. `undefined`는 할당되지 않은 값을 나타냅니다. -- `객체형` -- 복잡한 데이터 구조를 표현할 때 사용합니다. -- `심볼형` -- 객체의 고유 식별자를 만들 때 사용합니다. -======= -- Seven primitive data types: - - `number` for numbers of any kind: integer or floating-point, integers are limited by ±(253-1). - - `bigint` for integer numbers of arbitrary length. - - `string` for strings. A string may have zero or more characters, there's no separate single-character type. - - `boolean` for `true`/`false`. - - `null` for unknown values -- a standalone type that has a single value `null`. - - `undefined` for unassigned values -- a standalone type that has a single value `undefined`. - - `symbol` for unique identifiers. -- And one non-primitive data type: - - `object` for more complex data structures. ->>>>>>> upstream/master +- 원시 자료형 일곱 가지는 다음과 같습니다. + - `숫자형` -- 정수, 부동 소수점 숫자 등의 숫자를 나타낼 때 사용합니다. 정수의 한계는 ±(253-1) 입니다. + - `bigint` -- 길이 제약 없이 정수를 나타낼 수 있습니다. + - `문자형` -- 빈 문자열이나 글자들로 이뤄진 문자열을 나타낼 때 사용합니다. 단일 문자를 나타내는 별도의 자료형은 없습니다. + - `불린형` -- `true`, `false`를 나타낼 때 사용합니다. + - `null` -- `null` 값만을 위한 독립 자료형입니다. `null`은 알 수 없는 값을 나타냅니다. + - `undefined` -- `undefined` 값만을 위한 독립 자료형입니다. `undefined`는 할당되지 않은 값을 나타냅니다. + - `심볼형` -- 객체의 고유 식별자를 만들 때 사용합니다. +- 그리고 원시 자료형이 아닌 자료형이 하나 있습니다. + - `객체형` -- 복잡한 데이터 구조를 표현할 때 사용합니다. `typeof` 연산자는 피연산자의 자료형을 알려줍니다. -<<<<<<< HEAD -- `typeof x` 또는 `typeof(x)` 형태로 사용합니다. +- 보통 `typeof x` 형태로 사용하지만, `typeof(x)` 형태도 가능합니다. - 피연산자의 자료형을 문자열 형태로 반환합니다. -- `null`의 typeof 연산은 `"object"`인데, 이는 언어상 오류입니다. null은 객체가 아닙니다. -======= -- Usually used as `typeof x`, but `typeof(x)` is also possible. -- Returns a string with the name of the type, like `"string"`. -- For `null` returns `"object"` -- this is an error in the language, it's not actually an object. ->>>>>>> upstream/master +- `null`의 typeof 연산은 `"object"`인데, 이는 언어상 오류입니다. null은 객체가 아닙니다. 이어지는 챕터에선 원시 자료형에 대해 학습해 볼 예정입니다. 원시형에 어느 정도 익숙해지면 객체형에 대해 알아보도록 하겠습니다. From 355e1ffe9c6f4478edd48e45a29c6446d4598cb9 Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:24:01 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.6=20aler?= =?UTF-8?q?t,=20prompt,=20confirm=EC=9D=84=20=EC=9D=B4=EC=9A=A9=ED=95=9C?= =?UTF-8?q?=20=EC=83=81=ED=98=B8=EC=9E=91=EC=9A=A9=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20=EB=B0=8F=20=EB=B2=88=EC=97=AD=20=EC=A7=84?= =?UTF-8?q?=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index a75e46b18..e094ea75e 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -30,13 +30,8 @@ result = prompt(title, [default]); `default` : 입력 필드의 초깃값(선택값) -<<<<<<< HEAD ```smart header="인수를 감싸는 대괄호 `[...]`의 의미" `default`를 감싸는 대괄호는 이 매개변수가 필수가 아닌 선택값이라는 것을 의미합니다. -======= -```smart header="The square brackets in syntax `[...]`" -The square brackets around `default` in the syntax above denote that the parameter is optional, not required. ->>>>>>> upstream/master ``` 사용자는 프롬프트 대화상자의 입력 필드에 원하는 값을 입력하고 확인을 누를 수 있습니다. 값을 입력하길 원하지 않는 경우는 취소(Cancel) 버튼을 누르거나 `key:Esc`를 눌러 대화상자를 빠져나가면 됩니다. From a57efbaf624772223ca774c6cc9c087b7ce78d45 Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:24:09 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.7=20?= =?UTF-8?q?=ED=98=95=20=EB=B3=80=ED=99=98=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20=EB=B0=8F=20=EB=B2=88=EC=97=AD=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../07-type-conversions/article.md | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/1-js/02-first-steps/07-type-conversions/article.md b/1-js/02-first-steps/07-type-conversions/article.md index 254df1c54..ce5f4a5a7 100644 --- a/1-js/02-first-steps/07-type-conversions/article.md +++ b/1-js/02-first-steps/07-type-conversions/article.md @@ -6,13 +6,8 @@ 이 외에, 전달받은 값을 의도를 갖고 원하는 타입으로 변환(명시적 변환)해 주는 경우도 형 변환이라고 할 수 있습니다. -<<<<<<< HEAD -```smart header="객체의 형변환은 나중에 다룹니다." -이 챕터에선 객체는 다루지 않겠습니다. 여기선 원시형의 형변환에 대해서만 다룰 예정입니다. -======= -```smart header="Not talking about objects yet" -In this chapter, we won't cover objects. For now, we'll just be talking about primitives. ->>>>>>> upstream/master +```smart header="객체의 형 변환은 나중에 다룹니다." +이 챕터에선 객체는 다루지 않겠습니다. 여기선 원시형의 형 변환에 대해서만 다룰 예정입니다. 객체의 형 변환이 어떻게 이뤄지는지 에 대해선 객체에 대한 학습이 끝난 후 알아보겠습니다. ``` @@ -39,11 +34,7 @@ alert(typeof value); // string ## 숫자형으로 변환 -<<<<<<< HEAD 숫자형으로의 변환은 수학과 관련된 함수와 표현식에서 자동으로 일어납니다. -======= -Numeric conversion in mathematical functions and expressions happens automatically. ->>>>>>> upstream/master 숫자형이 아닌 값에 나누기 `/`를 적용한 경우와 같이 말이죠. @@ -78,13 +69,8 @@ alert(age); // NaN, 형 변환이 실패합니다. |-------|-------------| |`undefined`|`NaN`| |`null`|`0`| -<<<<<<< HEAD |true and false | `1` 과 `0` | -| `string` | 문자열의 처음과 끝 공백이 제거됩니다. 공백 제거 후 남아있는 문자열이 없다면 `0`, 그렇지 않다면 문자열에서 숫자를 읽습니다. 변환에 실패하면 `NaN`이 됩니다.| -======= -|true and false | `1` and `0` | -| `string` | Whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. | ->>>>>>> upstream/master +| `string` | 문자열의 처음과 끝 공백(스페이스, 탭 `\t`, 줄 바꿈 `\n` 등)이 제거됩니다. 공백 제거 후 남아있는 문자열이 없다면 `0`, 그렇지 않다면 문자열에서 숫자를 읽습니다. 변환에 실패하면 `NaN`이 됩니다.| 예시: @@ -144,11 +130,7 @@ alert( Boolean(" ") ); // 공백이 있는 문자열도 비어있지 않은 문 |`undefined`|`NaN`| |`null`|`0`| |true / false | `1 / 0` | -<<<<<<< HEAD -| `string` | 전달받은 문자열을 "그대로" 읽되, 처음과 끝의 공백을 무시합니다. 문자열이 비어있다면 `0`이 되고, 오류 발생 시 `NaN`이 됩니다. | -======= -| `string` | The string is read "as is", whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. | ->>>>>>> upstream/master +| `string` | 전달받은 문자열을 "그대로" 읽되, 처음과 끝의 공백(스페이스, 탭 `\t`, 줄 바꿈 `\n` 등)을 무시합니다. 문자열이 비어있다면 `0`이 되고, 오류 발생 시 `NaN`이 됩니다. | **`불린형으로 변환`** 은 논리 연산 시 발생합니다. `Boolean(value)`으로도 변환할 수 있습니다. From 9cd806bfac5beb9598317080663a0bba9e3b709b Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:24:16 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.8=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=97=B0=EC=82=B0=EC=9E=90=EC=99=80=20?= =?UTF-8?q?=EC=88=98=ED=95=99=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4=EA=B2=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B2=88=EC=97=AD=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution.md | 18 +-- .../08-operators/4-fix-prompt/solution.md | 4 - 1-js/02-first-steps/08-operators/article.md | 104 ++++-------------- 3 files changed, 23 insertions(+), 103 deletions(-) diff --git a/1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md b/1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md index 189b06db8..b2d473fe1 100644 --- a/1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md +++ b/1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md @@ -16,20 +16,10 @@ undefined + 1 = NaN // (6) " \t \n" - 2 = -2 // (7) ``` -<<<<<<< HEAD -1. 피 연산자 중 하나가 문자열인 `"" + 1`에서 `1`은 문자형으로 변환됩니다. 따라서 공백과 문자열 1을 더한, `"" + 1 = "1"`과 같은 효과를 발휘하죠. 그다음 연산 `"1" + 0`에도 같은 규칙이 적용됩니다. +1. 피연산자 중 하나가 문자열인 `"" + 1`에서 `1`은 문자형으로 변환됩니다. 따라서 공백과 문자열 1을 더한, `"" + 1 = "1"`과 같은 효과를 발휘하죠. 그다음 연산 `"1" + 0`에도 같은 규칙이 적용됩니다. 2. 뺄셈 연산자 `-`는 기타 수학 연산자처럼 숫자형만을 인수로 받습니다. 빈 문자열 `""`는 숫자 `0`으로 변환되기 때문에 결과는 `-1`이 됩니다. -3. 피 연산자 중 하나가 문자열이므로 숫자 5가 문자열로 변환됩니다. +3. 피연산자 중 하나가 문자열이므로 숫자 5가 문자열로 변환됩니다. 4. 뺄셈 연산자는 인수를 숫자형으로 변화시키므로 `" -9 "`는 숫자 `-9`로 변합니다. 앞, 뒤 공백은 제거되죠. 5. 숫자형으로 변환 시 `null`은 `0`이 됩니다. -6. `undefined`는 숫자형으로 변환시 `NaN`이 됩니다. -7. 문자열이 숫자형으로 변할 땐 문자열 앞뒤의 공백이 삭제됩니다. 뺄셈 연산자 앞의 피연산자는 공백을 만드는 문자 `\t`와 `\n`, 그 사이의 "일반적인" 공백으로 구성됩니다. 따라서 `" \t \n"`는 숫자형으로 변환 시 길이가 `0`인 문자열로 취급되어 숫자 `0`이 됩니다. -======= -1. The addition with a string `"" + 1` converts `1` to a string: `"" + 1 = "1"`, and then we have `"1" + 0`, the same rule is applied. -2. The subtraction `-` (like most math operations) only works with numbers, it converts an empty string `""` to `0`. -3. The addition with a string appends the number `5` to the string. -4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it). -5. `null` becomes `0` after the numeric conversion. -6. `undefined` becomes `NaN` after the numeric conversion. -7. Space characters are trimmed off string start and end when a string is converted to a number. Here the whole string consists of space characters, such as `\t`, `\n` and a "regular" space between them. So, similarly to an empty string, it becomes `0`. ->>>>>>> upstream/master +6. `undefined`는 숫자형으로 변환 시 `NaN`이 됩니다. +7. 문자열이 숫자형으로 변할 땐 문자열 앞뒤의 공백이 삭제됩니다. 뺄셈 연산자 앞의 피연산자는 공백을 만드는 문자 `\t`와 `\n`, 그 사이의 "일반적인" 공백으로 구성됩니다. 따라서 `" \t \n"`는 숫자형으로 변환 시 길이가 `0`인 문자열로 취급되어 숫자 `0`이 됩니다. \ No newline at end of file diff --git a/1-js/02-first-steps/08-operators/4-fix-prompt/solution.md b/1-js/02-first-steps/08-operators/4-fix-prompt/solution.md index 9c54fb346..defe5642c 100644 --- a/1-js/02-first-steps/08-operators/4-fix-prompt/solution.md +++ b/1-js/02-first-steps/08-operators/4-fix-prompt/solution.md @@ -9,11 +9,7 @@ let b = "2"; // prompt("덧셈할 두 번째 숫자를 입력해주세요.", 2); alert(a + b); // 12 ``` -<<<<<<< HEAD 예시가 제대로 동작하게 하려면 덧셈 연산 `+`가 수행되기 전에 문자열을 숫자로 변환해야 합니다. 이때 `Number()`를 사용하거나 변수 앞에 `+`를 붙여줄 수 있습니다. -======= -What we should do is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`. ->>>>>>> upstream/master 아래 코드에선 `prompt` 함수 바로 앞에서 문자열을 숫자로 변환했습니다. diff --git a/1-js/02-first-steps/08-operators/article.md b/1-js/02-first-steps/08-operators/article.md index b43d9ae0c..0cc15e3ca 100644 --- a/1-js/02-first-steps/08-operators/article.md +++ b/1-js/02-first-steps/08-operators/article.md @@ -50,46 +50,28 @@ 예시: ```js run -<<<<<<< HEAD alert( 5 % 2 ); // 5를 2로 나눈 후의 나머지인 1을 출력 alert( 8 % 3 ); // 8을 3으로 나눈 후의 나머지인 2를 출력 -======= -alert( 5 % 2 ); // 1, the remainder of 5 divided by 2 -alert( 8 % 3 ); // 2, the remainder of 8 divided by 3 -alert( 8 % 4 ); // 0, the remainder of 8 divided by 4 ->>>>>>> upstream/master +alert( 8 % 4 ); // 8을 4으로 나눈 후의 나머지인 0를 출력 ``` ## 거듭제곱 연산자 ** -<<<<<<< HEAD 거듭제곱 연산자(exponentiation operator)를 사용한 `a ** b`를 평가하면 `a`를 `b`번 곱한 값이 반환됩니다. -======= -The exponentiation operator `a ** b` raises `a` to the power of `b`. -In school maths, we write that as ab. ->>>>>>> upstream/master +학교 수학에선 이를 ab로 표기합니다. 예시: ```js run -<<<<<<< HEAD -alert( 2 ** 2 ); // 4 (2 * 2) -alert( 2 ** 3 ); // 8 (2 * 2 * 2) -alert( 2 ** 4 ); // 16 (2 * 2 * 2 * 2) -``` - -거듭제곱 연산자는 정수가 아닌 숫자에 대해서도 동작합니다. `1/2`을 사용하면 제곱근을 구할 수 있죠. -======= alert( 2 ** 2 ); // 2² = 4 alert( 2 ** 3 ); // 2³ = 8 alert( 2 ** 4 ); // 2⁴ = 16 ``` -Just like in maths, the exponentiation operator is defined for non-integer numbers as well. +수학에서와 마찬가지로, 거듭제곱 연산자는 정수가 아닌 숫자에 대해서도 동작합니다. -For example, a square root is an exponentiation by ½: ->>>>>>> upstream/master +예를 들어, 제곱근은 ½ 제곱으로 나타낼 수 있습니다. ```js run alert( 4 ** (1/2) ); // 2 (1/2 거듭제곱은 제곱근) @@ -99,11 +81,7 @@ alert( 8 ** (1/3) ); // 2 (1/3 거듭제곱은 세제곱근) ## 이항 연산자 '+'와 문자열 연결 -<<<<<<< HEAD 이제 학교에서 배운 기본 산술 연산자를 넘어, 자바스크립트가 제공하는 특별한 연산자 기능에 대해 살펴봅시다. -======= -Let's meet the features of JavaScript operators that are beyond school arithmetics. ->>>>>>> upstream/master 덧셈 연산자 `+`는 대개 숫자를 더한 결과를 반환합니다. @@ -131,16 +109,12 @@ alert( 2 + '1' ); // "21" alert(2 + 2 + '1' ); // '221'이 아니라 '41'이 출력됩니다. ``` -<<<<<<< HEAD -연산은 왼쪽에서 오른쪽으로 순차적으로 진행되기 때문에 이런 결과가 나왔습니다. 두 개의 숫자 뒤에 문자열이 오는 경우, 숫자가 먼저 더해지고, 그 후 더해진 숫자와 문자열과의 병합이 일어납니다. -======= -Here, operators work one after another. The first `+` sums two numbers, so it returns `4`, then the next `+` adds the string `1` to it, so it's like `4 + '1' = '41'`. +여기서는 연산자가 하나씩 순서대로 동작합니다. 첫 번째 `+`는 두 숫자를 더하므로 `4`를 반환하고, 그다음 `+`는 여기에 문자열 `'1'`을 더하므로 `4 + '1' = '41'`과 같은 결과가 됩니다. ```js run -alert('1' + 2 + 2); // "122" and not "14" +alert('1' + 2 + 2); // "14"가 아니라 "122"가 출력됩니다. ``` -Here, the first operand is a string, the compiler treats the other two operands as strings too. The `2` gets concatenated to `'1'`, so it's like `'1' + 2 = "12"` and `"12" + 2 = "122"`. ->>>>>>> upstream/master +첫 번째 피연산자가 문자열이므로, 컴파일러는 나머지 두 피연산자도 문자열로 취급합니다. 2가 '1'에 병합되므로, '1' + 2 = "12"가 되고 "12" + 2 = "122"가 됩니다. 이처럼 이항 덧셈 연산자 `+`는 문자열 연결과 변환이라는 특별한 기능을 제공합니다. 다른 산술 연산자가 오직 숫자형의 피연산자만 다루고, 피연산자가 숫자형이 아닌 경우에 그 형을 숫자형으로 바꾸는 것과는 대조적입니다. @@ -216,51 +190,27 @@ alert( +apples + +oranges ); // 5 자바스크립트는 다양한 연산자를 제공하는데, 이 모든 연산자엔 우선순위가 매겨져 있습니다. 우선순위 숫자가 클수록 먼저 실행됩니다. 순위가 같으면 왼쪽부터 시작해서 오른쪽으로 연산이 수행됩니다. -<<<<<<< HEAD 아래는 [우선순위 테이블(precedence table)](https://developer.mozilla.org/en/JavaScript/Reference/operators/operator_precedence)의 일부를 발췌한 표입니다. 순서를 기억할 필요는 없지만, 동일한 기호의 단항 연산자는 이항 연산자보다 우선순위가 더 높다는 것에 주목해 주시기 바랍니다. | 순위 | 연산자 이름 | 기호 | | --- | ------ | --- | | ... | ... | ... | -| 17 | 단항 덧셈 | `+` | -| 17 | 단항 부정 | `-` | -| 16 | 지수 | `**` | -| 15 | 곱셈 | `*` | -| 15 | 나눗셈 | `/` | -| 13 | 덧셈 | `+` | -| 13 | 뺄셈 | `-` | +| 14 | 단항 덧셈 | `+` | +| 14 | 단항 부정 | `-` | +| 13 | 거듭제곱 | `**` | +| 12 | 곱셈 | `*` | +| 12 | 나눗셈 | `/` | +| 11 | 덧셈 | `+` | +| 11 | 뺄셈 | `-` | | ... | ... | ... | -| 3 | 할당 | `=` | +| 2 | 할당 | `=` | | ... | ... | ... | -'단항 덧셈 연산자'는 우선순위 `17`로, '(이항) 덧셈 연산자'의 우선순위 `13`보다 높습니다. 표현식 `"+apples + +oranges"`에서 단항 덧셈 연산자가 덧셈보다 먼저 수행되는 이유가 바로 이 때문입니다. -======= -Here's an extract from the [precedence table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) (you don't need to remember this, but note that unary operators are higher than corresponding binary ones): - -| Precedence | Name | Sign | -|------------|------|------| -| ... | ... | ... | -| 14 | unary plus | `+` | -| 14 | unary negation | `-` | -| 13 | exponentiation | `**` | -| 12 | multiplication | `*` | -| 12 | division | `/` | -| 11 | addition | `+` | -| 11 | subtraction | `-` | -| ... | ... | ... | -| 2 | assignment | `=` | -| ... | ... | ... | - -As we can see, the "unary plus" has a priority of `14` which is higher than the `11` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition. ->>>>>>> upstream/master +'단항 덧셈 연산자'는 우선순위 `14`로, '(이항) 덧셈 연산자'의 우선순위 `11`보다 높습니다. 표현식 `"+apples + +oranges"`에서 단항 덧셈 연산자가 덧셈보다 먼저 수행되는 이유가 바로 이 때문입니다. ## 할당 연산자 -<<<<<<< HEAD -무언가를 할당할 때 쓰이는 `=`도 연산자입니다. 이 연산자는 할당(assignment) 연산자라고 불리는데, 우선순위는 `3`으로 아주 낮습니다. -======= -Let's note that an assignment `=` is also an operator. It is listed in the precedence table with the very low priority of `2`. ->>>>>>> upstream/master +무언가를 할당할 때 쓰이는 `=`도 연산자입니다. 이 연산자는 할당(assignment) 연산자라고 불리는데, 우선순위는 `2`으로 아주 낮습니다. `x = 2 * 2 + 1`과 같은 표현식에서 계산이 먼저 이뤄지고, 그 결과가 `x`에 할당되는 이유가 바로 이 때문입니다. @@ -274,11 +224,7 @@ alert( x ); // 5 `=`는 연산자이기 때문에 흥미로운 함축성을 내포하고 있습니다. -<<<<<<< HEAD -자바스크립트에서 대부분의 연산자들은 값을 반환합니다. `+`와 `-`뿐만 아니라 `=` 역시 값을 반환하죠. -======= -All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`. ->>>>>>> upstream/master +자바스크립트의 모든 연산자는 값을 반환합니다. `+`와 `-`뿐만 아니라 `=` 역시 값을 반환하죠. `x = value`을 호출하면 `value`가 `x`에 쓰여지고, 이에 더하여 *`value`가 반환됩니다*. @@ -320,11 +266,7 @@ alert( c ); // 4 이렇게 할당 연산자를 여러 개 연결한 경우, 평가는 우측부터 진행됩니다. 먼저 가장 우측의 `2 + 2`가 평가되고, 그 결과가 좌측의 `c`, `b`, `a`에 순차적으로 할당됩니다. 모든 변수가 단일 값을 공유하게 되죠. -<<<<<<< HEAD 그런데 되도록이면 연산자를 체이닝 하는것 보다 가독성을 위해 아래와 같이 줄을 나눠 코드를 작성하길 권유드립니다. -======= -Once again, for the purposes of readability it's better to split such code into a few lines: ->>>>>>> upstream/master ```js c = 2 + 2; @@ -364,11 +306,7 @@ let n = 2; n *= 3 + 5; // right part evaluated first, same as n *= 8 -<<<<<<< HEAD -alert( n ); // 16 (*=의 우측이 먼저 평가되므로, 위 식은 n *= 8과 동일합니다.) -======= alert( n ); // 16 ->>>>>>> upstream/master ``` ## 증가·감소 연산자 @@ -500,11 +438,7 @@ counter++; - 오른쪽 시프트(RIGHT SHIFT) ( `>>` ) - 부호 없는 오른쪽 시프트(ZERO-FILL RIGHT SHIFT) ( `>>>` ) -<<<<<<< HEAD -비트 연산자는 저수준(2진 표현)에서 숫자를 다뤄야 할 때 쓰이므로 흔하게 쓰이진 않습니다. 웹 개발 시엔 이런 일이 자주 일어나지 않기 때문에 비트 연산자를 만날 일은 거의 없죠. 그렇긴 해도 암호를 다뤄야 할 땐 비트 연산자가 유용하기 때문에 때가 되면 MDN의 [비트 연산자](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators) 문서를 보시는 걸 추천합니다. -======= -These operators are used very rarely, when we need to fiddle with numbers on the very lowest (bitwise) level. We won't need these operators any time soon, as web development has little use of them, but in some special areas, such as cryptography, they are useful. You can read the [Bitwise Operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise_operators) chapter on MDN when a need arises. ->>>>>>> upstream/master +비트 연산자는 저수준(2진 표현)에서 숫자를 다뤄야 할 때 쓰이므로 흔하게 쓰이진 않습니다. 웹 개발 시엔 이런 일이 자주 일어나지 않기 때문에 비트 연산자를 만날 일은 거의 없죠. 그렇긴 해도 암호를 다뤄야 할 땐 비트 연산자가 유용하기 때문에 때가 되면 MDN의 [비트 연산자](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise_operators) 문서를 보시는 걸 추천합니다. ## 쉼표 연산자 From a41383a1f3e6b64f9a41c7d3281973a8d6162ac8 Mon Sep 17 00:00:00 2001 From: electrohyun Date: Sun, 17 May 2026 20:24:26 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[=EB=AC=B8=EC=84=9C]=20C02=20-=202.9=20?= =?UTF-8?q?=EB=B9=84=EA=B5=90=20=EC=97=B0=EC=82=B0=EC=9E=90=20=EC=B6=A9?= =?UTF-8?q?=EB=8F=8C=20=ED=95=B4=EA=B2=B0=20=EB=B0=8F=20=EB=B2=88=EC=97=AD?= =?UTF-8?q?=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1-comparison-questions/solution.md | 12 +------ 1-js/02-first-steps/09-comparison/article.md | 31 +++---------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md b/1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md index c310d6efa..7df9f8ace 100644 --- a/1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md +++ b/1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md @@ -12,20 +12,10 @@ null === +"\n0\n" → false 해설: -<<<<<<< HEAD 1. 명백히 true입니다. 2. 문자열의 비교는 사전순서가 기준이므로 false입니다. `"a"`는 `"p"`보다 작습니다. -3. 두 피연산자는 문자열이므로, 사전순으로 비교가 이뤄집니다. 왼쪽 피연산자의 첫 번째 글자 `"2"`는 오른쪽 피연산자의 첫 번째 글자 `"1"`보다 큽니다. +3. 두 피연산자는 문자열이므로, 사전 순으로 비교가 이뤄집니다. 왼쪽 피연산자의 첫 번째 글자 `"2"`는 오른쪽 피연산자의 첫 번째 글자 `"1"`보다 큽니다. 4. `null`과 `undefined`는 같습니다. 5. 일치 연산자는 형도 체크합니다. 형이 다르면 false가 반환됩니다. 6. (4)와 유사한 문제입니다. `null`은 오직 `undefined`와 같습니다. 7. 형이 다르므로 false가 반환됩니다. -======= -1. Obviously, true. -2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`. -3. Again, dictionary comparison, first char `"2"` is greater than the first char `"1"`. -4. Values `null` and `undefined` equal each other only. -5. Strict equality is strict. Different types from both sides lead to false. -6. Similar to `(4)`, `null` only equals `undefined`. -7. Strict equality of different types. ->>>>>>> upstream/master diff --git a/1-js/02-first-steps/09-comparison/article.md b/1-js/02-first-steps/09-comparison/article.md index 974ab55b5..d1c9b9731 100644 --- a/1-js/02-first-steps/09-comparison/article.md +++ b/1-js/02-first-steps/09-comparison/article.md @@ -4,25 +4,14 @@ 자바스크립트에서 기본 수학 연산은 아래와 같은 문법을 사용해 표현할 수 있습니다. -<<<<<<< HEAD - 보다 큼·작음: a > b, a < b - 보다 크거나·작거나 같음: a >= b, a <= b - 같음(동등): `a == b`. 등호 `=`가 두 개 연달아 오는 것에 유의하세요. `a ​​= b`와 같이 등호가 하나일 때는 할당을 의미합니다. -- 같지 않음(부등): 같지 않음을 나타내는 수학 기호 는 자바스크립트에선 a != b로 나타냅니다. 할당연산자 `=` 앞에 느낌표 `!`를 붙여서 표시합니다. +- 같지 않음(부등): 같지 않음을 나타내는 수학 기호 는 자바스크립트에선 a != b로 나타냅니다. 이번 글에선 비교 시 일어나는 기이한 현상을 포함하여 다양한 자료형을 대상으로 자바스크립트가 어떻게 비교를 하는지에 대해 다룰 예정입니다. 글 말미에는 자바스크립트에서만 일어나는 '기이한' 현상을 어떻게 예방할 수 있는지에 대해서 언급해두었습니다. -======= -- Greater/less than: a > b, a < b. -- Greater/less than or equals: a >= b, a <= b. -- Equals: `a == b`, please note the double equality sign `==` means the equality test, while a single one `a = b` means an assignment. -- Not equals: In maths the notation is , but in JavaScript it's written as a != b. - -In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities. - -At the end you'll find a good recipe to avoid "JavaScript quirks"-related issues. ->>>>>>> upstream/master ## 불린형 반환 @@ -68,13 +57,9 @@ alert( 'Bee' > 'Be' ); // true 4. 글자 간 비교가 끝날 때까지 이 과정을 반복합니다. 5. 비교가 종료되었고 문자열의 길이도 같다면 두 문자열은 동일하다고 결론 냅니다. 비교가 종료되었지만 두 문자열의 길이가 다르면 길이가 긴 문자열이 더 크다고 결론 냅니다. -<<<<<<< HEAD -예시의 `'Z' > 'A'`는 위 알고리즘의 첫 번째 단계에서 비교 결과가 도출됩니다. 반면, 문자열 `'Glow'`와 `'Glee'`는 복수의 문자로 이루어진 문자열이기 때문에, 아래와 같은 순서로 문자열 비교가 이뤄집니다. -======= -In the first example above, the comparison `'Z' > 'A'` gets to a result at the first step. +위 첫 번째 예시에서 `'Z' > 'A'` 비교는 첫 번째 단계에서 결과가 도출됩니다. -The second comparison `'Glow'` and `'Glee'` needs more steps as strings are compared character-by-character: ->>>>>>> upstream/master +두 번째 비교인 `'Glow'`와 `'Glee'`는 문자열이 글자 단위로 비교되므로 더 많은 단계가 필요합니다. 1. `G`는 `G`와 같습니다. 2. `l`은 `l`과 같습니다. @@ -224,16 +209,8 @@ alert( undefined == 0 ); // false (3) ## 요약 -<<<<<<< HEAD - 비교 연산자는 불린값을 반환합니다. - 문자열은 문자 단위로 비교되는데, 이때 비교 기준은 '사전' 순입니다. - 서로 다른 타입의 값을 비교할 땐 숫자형으로 형 변환이 이뤄지고 난 후 비교가 진행됩니다(일치 연산자는 제외). - `null`과 `undefined`는 동등 비교(`==`) 시 서로 같지만 다른 값과는 같지 않습니다. -- `null`이나 `undefined`가 될 확률이 있는 변수가 `>` 또는 `<`의 피연산자로 올 때는 주의를 기울이시기 바랍니다. `null`, `undefined` 여부를 확인하는 코드를 따로 추가하는 습관을 들이길 권유합니다. -======= -- Comparison operators return a boolean value. -- Strings are compared letter-by-letter in the "dictionary" order. -- When values of different types are compared, they get converted to numbers (with the exclusion of a strict equality check). -- The values `null` and `undefined` are equal `==` to themselves and each other, but do not equal any other value. -- Be careful when using comparisons like `>` or `<` with variables that can occasionally be `null/undefined`. Checking for `null/undefined` separately is a good idea. ->>>>>>> upstream/master +- `null`이나 `undefined`가 될 확률이 있는 변수가 `>` 또는 `<`의 피연산자로 올 때는 주의를 기울이시기 바랍니다. `null`, `undefined` 여부를 확인하는 코드를 따로 추가하는 습관을 들이길 권유합니다. \ No newline at end of file