Chap. 1 eloquent javascript Flashcards

1
Q

(100 + 4) * 11

A

1,144

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

What character to use to get a space at “And”

“This is the first line And this is the second”

A

\n

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

write out:

“A newline character is written like “\n”.”

as code

A

“A newline character is written like "\n”.”

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

The following returns?

console.log(half of 100 is ${100 / 2} );

A

‘Half of 100 is 50’

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

${} is called

A

template literal

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

The following returns:

console.log(- (10 - 2))

A

-8

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

console. log(typeof 4.5)

console. log(typeof “x”)

A
// → number
// → string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

console.log(3 > 2)

A

// → true

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

console.log(3 < 2)

A

// → false

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

console.log(“Itchy” != “Scratchy”)

A

// → true

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

console.log(“Apple” == “Orange”)

A

// → false

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

console.log(NaN == NaN)

A

// → false

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

> =

A

greater than or equal too

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

<=

A

less than or equal too

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

!=

A

not equal too

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

= =

A

equal too

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

console.log(true && false)

A

// → false

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

console.log(true && true)

A

// → true

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

console.log(false || true)

A

// → true

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

console.log(false || false)

A

// → false

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

!true

A

False

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

!False

A

True

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

console.log(true ? 1 : 2);

A

// → 1

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

console.log(false ? 1 : 2);

A

// → 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
There are two special values, written ____ and ____, that are used to denote the absence of a meaningful value
Null undefined
26
console.log(8 * null)
// → 0
27
console.log("5" - 1)
// → 4
28
console.log("5" + 1)
// → 51
29
console.log("five" * 2)
// → NaN
30
console.log(false == 0)
// → true
31
console.log(true == 0);
// → false
32
When something that doesn’t map to a number in an obvious way (such as "five" or undefined) is converted to a number, you get the value
NaN
33
console.log(null == undefined);
// → true
34
console.log(null == 0);
// → false
35
console.log(" " == false);
// → true
36
console.log(" " === false);
// → false
37
console.log(null || "user")
// → user
38
console.log("Agnes" || "user")
// → Agnes
39
console.log(NAN || "user")
reference error
40
The rules for converting strings and numbers to Boolean values state that 0, NaN, and the empty string ("") count as
false
41
console.log(0 || -1)
-1
42
console.log(0 && -1)
0
43
console.log(-1 && 0)
0
44
console.log(-1 || 0)
-1
45
console.log(1 - 2 + 1)
0
46
console.log(NaN == NaN)
flase
47
There is only one value in JavaScript that is not equal to itself, and that is ______
NaN
48
console.log(true !& true)
syntax error
49
``` var a = 3; var b = -2; console.log(!(a > 0 || b > 0)); ```
// false
50
If expr1 can be converted to true, returns expr2; else, returns expr1.
&& operator
51
If expr1 can be converted to true, returns expr1; else, returns expr2.
|| operator
52
Examples of expressions that can be converted to false are:
``` null; NaN; 0; empty string ("" or '' or ``); undefined.` ```
53
console.log(true || false && false); why?
// returns true, because && is executed first
54
console.log((true || false) && false); why?
// returns false, because operator precedence cannot apply
55
n3 = !''
// !f returns true
56
n4 = !'Cat'
// !t returns false
57
true || true
//true
58
o2 = false || true
// true
59
o3 = true || false
// true
60
o4 = false || (3 == 4)
// false
61
o5 = 'Cat' || 'Dog'
//"Cat"
62
o6 = false || 'Cat'
//"Cat"
63
o7 = 'Cat' || false
// "Cat"
64
o8 = '' || false
// false
65
o9 = false || ''
// ""
66
o10 = false || varObject /
// varObject
67
bCondition1 && bCondition2 | is always equal to:
!(!bCondition1 || !bCondition2)
68
bCondition1 || bCondition2 | is always equal to:
!(!bCondition1 && !bCondition2)
69
!!bCondition | is always equal to:
bCondition
70
console. log(true && true); console. log(true && false); console. log(false && true); console. log(false && false);
true false false false
71
console. log(true || true); console. log(true || false); console. log(false || true); console. log(false || false);
true true true false
72
This operator is frequently used as an alternative to an if...else statement.
Conditional (ternary) operator