Comparisons Flashcards

1
Q

a==b
write not equal to

A

a != b

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

let result = 5 > 4 // returns

A

true

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

alert( ‘Z’ > ‘A’ ); // returns
alert( ‘Bee’ > ‘Be’ ); // returns

A

true
true

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

alert( ‘Z’ > ‘Z’ ); // returns

A

false

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

alert( ‘Glow’ > ‘Glee’ ); // returns and why

A

true
o is greater than e.

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

A capital letter “A” is not equal to the lowercase “a”. Which one is greater and why?

A

The lowercase “a”. Why? Because the lowercase character has a greater index in the internal encoding table JavaScript uses (Unicode).

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

alert( ‘2’ > 1 ); // returns and why?

A

true, string ‘2’ becomes a number 2

JavaScript converts the values to numbers.

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

alert( ‘01’ == 1 ); // returns and why?

A

true, string ‘01’ becomes a number 1

JavaScript converts the values to numbers.

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

let a = 0;
let b = “0”;
alert(a == b); // returns and why

A

true

An equality check converts values using the numeric conversion (hence “0” becomes 0), while the explicit Boolean conversion uses another set of rules.

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

alert( 0 == false ); // returns

A

true

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

alert( 0 === false ); // returns and why

A

false

Because the types are different

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

alert( 0 !== false );

A

true

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

alert( null === undefined );

A

false

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

alert( null == undefined );

A

true

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

For maths and other comparisons < > <= >=
null is converted to ________

A

number

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

For maths and other comparisons < > <= >=
undefined becomes ________.

A

NAN

17
Q

alert( null > 0 ); // returns

A

false

18
Q

alert( null == 0 ); // returns and why?

A

false

the equality check == for undefined and null is defined such that, without any conversions, they equal each other and don’t equal anything else. That’s why (2) null == 0 is false.

19
Q

alert( null >= 0 ) // returns and why?

A

true

Comparisons convert null to a number, treating it as 0. That’s why (3) null >= 0 is true

20
Q

alert( undefined > 0 ); //

A

false

21
Q

alert( undefined < 0 ); // returns

A

false

22
Q

alert( undefined == 0 ); // returns

A

false