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/06-type-conversions/article.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ There are also cases when we need to explicitly convert a value to the expected
10
10
In this chapter, we won't cover objects. Instead, we'll study primitives first. Later, after we learn about objects, we'll see how object conversion works in the chapter <info:object-toprimitive>.
11
11
```
12
12
13
-
## ToString
13
+
## To String
14
14
15
15
String conversion happens when we need the string form of a value.
16
16
@@ -30,7 +30,7 @@ alert(typeof value); // string
30
30
31
31
String conversion is mostly obvious. A `false` becomes `"false"`, `null` becomes `"null"`, etc.
32
32
33
-
## ToNumber
33
+
## To Number
34
34
35
35
Numeric conversion happens in mathematical functions and expressions automatically.
36
36
@@ -94,7 +94,7 @@ alert( '1' + 2 ); // '12' (string to the left)
94
94
This only happens when at least one of the arguments is a string. Otherwise, values are converted to numbers.
95
95
````
96
96
97
-
## ToBoolean
97
+
## To Boolean
98
98
99
99
Boolean conversion is the simplest one.
100
100
@@ -129,9 +129,9 @@ alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
129
129
130
130
The three most widely used type conversions are to string, to number, and to boolean.
131
131
132
-
**`ToString`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
132
+
**`To String`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
133
133
134
-
**`ToNumber`** -- Occurs in math operations. Can be performed with `Number(value)`.
134
+
**`To Number`** -- Occurs in math operations. Can be performed with `Number(value)`.
135
135
136
136
The conversion follows the rules:
137
137
@@ -142,7 +142,7 @@ The conversion follows the rules:
142
142
|<code>true / false</code> | `1 / 0` |
143
143
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
144
144
145
-
**`ToBoolean`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
145
+
**`To Boolean`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
0 commit comments