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/05-data-types/01-primitives-methods/article.md
+2-18Lines changed: 2 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,25 +39,16 @@ john.sayHi(); // 친구야 반갑다!
39
39
40
40
자바스크립트 창안자(creator)는 다음과 같은 모순적인 상황을 해결해야만 했었습니다.
41
41
42
-
<<<<<<< HEAD
43
42
- 문자열이나 숫자와 같은 원시값을 다루어야 하는 작업이 많은데, 메서드를 사용하면 작업을 수월하게 할 수 있을 것 같다는 생각이 듭니다.
44
43
- 그런데 원시값은 가능한 한 빠르고 가벼워야 합니다.
45
-
=======
46
-
- There are many things one would want to do with a primitive, like a string or a number. It would be great to access them using methods.
47
-
- Primitives must be as fast and lightweight as possible.
48
-
>>>>>>> upstream/master
49
44
50
45
조금 어색해 보이지만, 자바스크립트 창안자는 아래와 같은 방법을 사용해 해결책을 모색하였습니다.
51
46
52
47
1. 원시값은 원시값 그대로 남겨둬 단일 값 형태를 유지합니다.
53
48
2. 문자열, 숫자, 불린, 심볼의 메서드와 프로퍼티에 접근할 수 있도록 언어 차원에서 허용합니다.
54
49
3. 이를 가능하게 하기 위해, 원시값이 메서드나 프로퍼티에 접근하려 하면 추가 기능을 제공해주는 특수한 객체, "원시 래퍼 객체(object wrapper)"를 만들어 줍니다. 이 객체는 곧 삭제됩니다.
55
50
56
-
<<<<<<< HEAD
57
-
"래퍼 객체"는 원시 타입에 따라 종류가 다양합니다. 각 래퍼 객체는 원시 자료형의 이름을 그대로 차용해, `String`,`Number`,`Boolean`, `Symbol`라고 부릅니다. 래퍼 객체 마다 제공하는 메서드 역시 다릅니다.
58
-
=======
59
-
The "object wrappers" are different for each primitive type and are called: `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. Thus, they provide different sets of methods.
60
-
>>>>>>> upstream/master
51
+
"래퍼 객체"는 원시 타입에 따라 종류가 다양합니다. 각 래퍼 객체는 원시 자료형의 이름을 그대로 차용해, `String`,`Number`,`Boolean`, `Symbol`, `BigInt` 라고 부릅니다. 래퍼 객체 마다 제공하는 메서드 역시 다릅니다.
61
52
62
53
인수로 받은 문자열의 모든 글자를 대문자로 바꿔주는 메서드 [str.toUpperCase()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)를 예로 들어보겠습니다.
63
54
@@ -113,16 +104,9 @@ if (zero) { // 변수 zero는 객체이므로, 조건문이 참이 됩니다.
113
104
}
114
105
```
115
106
116
-
<<<<<<< HEAD
117
-
그런데, `new`를 붙이지 않고 `String / Number / Boolean`을 사용하는 건 괜찮습니다. `new` 없이 사용하면 상식에 맞게 인수를 원하는 형의 원시값(문자열, 숫자, 불린 값)으로 바꿔줍니다. 아주 유용하죠.
107
+
그런데, `new`를 붙이지 않고 `String/Number/Boolean`을 사용하는 건 괜찮습니다. `new` 없이 사용하면 상식에 맞게 인수를 원하는 형의 원시값(문자열, 숫자, 불린 값)으로 바꿔줍니다. 아주 유용하죠.
118
108
119
109
예시:
120
-
=======
121
-
On the other hand, using the same functions `String/Number/Boolean` without `new` is totally fine and useful thing. They convert a value to the corresponding type: to a string, a number, or a boolean (primitive).
0 commit comments