20 Flashcards
(8 cards)
1
Q
Type conversion
A
manually convert types (explicitly)
Example: Number(‘1991’)
2
Q
Type coercion
A
JS automatically converts types (implicitly)
Example: ‘1991’ + 18 = ‘199118’
3
Q
Number(‘Jonas’)
A
NaN
(typeof NaN = number)
4
Q
type conversions that make sense
A
String → Number
Number → String
Number → Boolean
Boolean → Number
5
Q
Addition (+) converts to …
A
String
Example: ‘23’ + ‘10’ + 3 = ‘23103’
6
Q
Subtraction (-) converts to …
A
Number
Example: ‘23’ - ‘10’ - 3 = 10
7
Q
Multiplication (*) converts to …
A
Number
Example: ‘2’ * ‘3’ = 6
8
Q
Division (/) converts to …
A
Number
Example: ‘6’ / 2 = 3