Chapter 1: Values, Types, and Operators Flashcards

1
Q

JavaScript expression for the remainder of 10 divided by 3

A

10 % 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Three special numbers in JS

A

Infinity
-Infinity
NaN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Three ways to write a string in JS

A

“Double quotes”
‘Single quotes’
Backticks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Escape character in JS

A

Backslash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

String concatenation

A

+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a “template literal”?

A

A string which can embed a calculated or object value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you write a template literal?

A

Use backticks around text, with values to be computed surrounded by ${}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to return to type of a value

A

With the “typeof” operator: typeof “string” -> string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JS “and” operator

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JS “or” operator

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JS conditional operator (and example)

A

? :

false ? 7 : 3 -> 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is “type coercion?

A

When JS is told to use an operator on values of differing types, it will try to force on value to be the type of the other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you avoid false from getting automatically converted to 0 or “” in a comparison to a number or string?

A

Use === instead of == or !== instead of !=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is “short-circuit evaluation”?

A

A behavior in JS in which the only value in an expression that is evaluated is the value that is selected; non-selected values are not evaluated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give an example of short-circuit evaluation

A

true || “not selected” -> true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do && and || work on string and number values?

A

0, NaN, and “” count as false and all other strings and numbers count as true. If the number or string being evaluated as true or false is chosen by the operator, that same value is returned by the expression.