You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/07-type-conversions/article.md
+4-22Lines changed: 4 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,8 @@
6
6
7
7
이 외에, 전달받은 값을 의도를 갖고 원하는 타입으로 변환(명시적 변환)해 주는 경우도 형 변환이라고 할 수 있습니다.
8
8
9
-
<<<<<<< HEAD
10
-
```smart header="객체의 형변환은 나중에 다룹니다."
11
-
이 챕터에선 객체는 다루지 않겠습니다. 여기선 원시형의 형변환에 대해서만 다룰 예정입니다.
12
-
=======
13
-
```smart header="Not talking about objects yet"
14
-
In this chapter, we won't cover objects. For now, we'll just be talking about primitives.
15
-
>>>>>>> upstream/master
9
+
```smart header="객체의 형 변환은 나중에 다룹니다."
10
+
이 챕터에선 객체는 다루지 않겠습니다. 여기선 원시형의 형 변환에 대해서만 다룰 예정입니다.
16
11
17
12
객체의 형 변환이 어떻게 이뤄지는지 <info:object-toprimitive>에 대해선 객체에 대한 학습이 끝난 후 알아보겠습니다.
18
13
```
@@ -39,11 +34,7 @@ alert(typeof value); // string
39
34
40
35
## 숫자형으로 변환
41
36
42
-
<<<<<<< HEAD
43
37
숫자형으로의 변환은 수학과 관련된 함수와 표현식에서 자동으로 일어납니다.
44
-
=======
45
-
Numeric conversion in mathematical functions and expressions happens automatically.
46
-
>>>>>>> upstream/master
47
38
48
39
숫자형이 아닌 값에 나누기 `/`를 적용한 경우와 같이 말이죠.
49
40
@@ -78,13 +69,8 @@ alert(age); // NaN, 형 변환이 실패합니다.
78
69
|-------|-------------|
79
70
|`undefined`|`NaN`|
80
71
|`null`|`0`|
81
-
<<<<<<< HEAD
82
72
|<code>true and false</code> |`1` 과 `0`|
83
-
|`string`| 문자열의 처음과 끝 공백이 제거됩니다. 공백 제거 후 남아있는 문자열이 없다면 `0`, 그렇지 않다면 문자열에서 숫자를 읽습니다. 변환에 실패하면 `NaN`이 됩니다.|
84
-
=======
85
-
|<code>true and false</code> |`1` and `0`|
86
-
|`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`. |
87
-
>>>>>>> upstream/master
73
+
|`string`| 문자열의 처음과 끝 공백(스페이스, 탭 `\t`, 줄 바꿈 `\n` 등)이 제거됩니다. 공백 제거 후 남아있는 문자열이 없다면 `0`, 그렇지 않다면 문자열에서 숫자를 읽습니다. 변환에 실패하면 `NaN`이 됩니다.|
88
74
89
75
예시:
90
76
@@ -144,11 +130,7 @@ alert( Boolean(" ") ); // 공백이 있는 문자열도 비어있지 않은 문
144
130
|`undefined`|`NaN`|
145
131
|`null`|`0`|
146
132
|<code>true / false</code> | `1 / 0` |
147
-
<<<<<<< HEAD
148
-
| `string` | 전달받은 문자열을 "그대로" 읽되, 처음과 끝의 공백을 무시합니다. 문자열이 비어있다면 `0`이 되고, 오류 발생 시 `NaN`이 됩니다. |
149
-
=======
150
-
| `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`. |
151
-
>>>>>>> upstream/master
133
+
| `string` | 전달받은 문자열을 "그대로" 읽되, 처음과 끝의 공백(스페이스, 탭 `\t`, 줄 바꿈 `\n` 등)을 무시합니다. 문자열이 비어있다면 `0`이 되고, 오류 발생 시 `NaN`이 됩니다. |
152
134
153
135
**`불린형으로 변환`** 은 논리 연산 시 발생합니다. `Boolean(value)`으로도 변환할 수 있습니다.
0 commit comments