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
Q

There are two special values, written ____ and ____, that are used to denote the absence of a meaningful value

A

Null

undefined

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

console.log(8 * null)

A

// → 0

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

console.log(“5” - 1)

A

// → 4

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

console.log(“5” + 1)

A

// → 51

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

console.log(“five” * 2)

A

// → NaN

30
Q

console.log(false == 0)

A

// → true

31
Q

console.log(true == 0);

A

// → false

32
Q

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

A

NaN

33
Q

console.log(null == undefined);

A

// → true

34
Q

console.log(null == 0);

A

// → false

35
Q

console.log(“ “ == false);

A

// → true

36
Q

console.log(“ “ === false);

A

// → false

37
Q

console.log(null || “user”)

A

// → user

38
Q

console.log(“Agnes” || “user”)

A

// → Agnes

39
Q

console.log(NAN || “user”)

A

reference error

40
Q

The rules for converting strings and numbers to Boolean values state that 0, NaN, and the empty string (“”) count as

A

false

41
Q

console.log(0 || -1)

A

-1

42
Q

console.log(0 && -1)

A

0

43
Q

console.log(-1 && 0)

A

0

44
Q

console.log(-1 || 0)

A

-1

45
Q

console.log(1 - 2 + 1)

A

0

46
Q

console.log(NaN == NaN)

A

flase

47
Q

There is only one value in JavaScript that is not equal to itself, and that is ______

A

NaN

48
Q

console.log(true !& true)

A

syntax error

49
Q
var a = 3;
var b = -2;
console.log(!(a > 0 || b > 0));
A

// false

50
Q

If expr1 can be converted to true, returns expr2; else, returns expr1.

A

&& operator

51
Q

If expr1 can be converted to true, returns expr1; else, returns expr2.

A

|| operator

52
Q

Examples of expressions that can be converted to false are:

A
null;
NaN;
0;
empty string ("" or '' or ``); 
undefined.`
53
Q

console.log(true || false && false); why?

A

// returns true, because && is executed first

54
Q

console.log((true || false) && false); why?

A

// returns false, because operator precedence cannot apply

55
Q

n3 = !’’

A

// !f returns true

56
Q

n4 = !’Cat’

A

// !t returns false

57
Q

true || true

A

//true

58
Q

o2 = false || true

A

// true

59
Q

o3 = true || false

A

// true

60
Q

o4 = false || (3 == 4)

A

// false

61
Q

o5 = ‘Cat’ || ‘Dog’

A

//”Cat”

62
Q

o6 = false || ‘Cat’

A

//”Cat”

63
Q

o7 = ‘Cat’ || false

A

// “Cat”

64
Q

o8 = ‘’ || false

A

// false

65
Q

o9 = false || ‘’

A

// “”

66
Q

o10 = false || varObject /

A

// varObject

67
Q

bCondition1 && bCondition2

is always equal to:

A

!(!bCondition1 || !bCondition2)

68
Q

bCondition1 || bCondition2

is always equal to:

A

!(!bCondition1 && !bCondition2)

69
Q

!!bCondition

is always equal to:

A

bCondition

70
Q

console. log(true && true);
console. log(true && false);
console. log(false && true);
console. log(false && false);

A

true
false
false
false

71
Q

console. log(true || true);
console. log(true || false);
console. log(false || true);
console. log(false || false);

A

true
true
true
false

72
Q

This operator is frequently used as an alternative to an if…else statement.

A

Conditional (ternary) operator