Types & Equality Flashcards

1
Q

What does the below code print out?

    if (undefined == null) {
        console.log("Moo")
    } else {
        console.log("Zoo")
    }
A

They are actually values that can be checked for equality

Moo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
// What does the below code print out?
    console.log(typeof(null));
A

It should be “null” but javascript incorrectly reports the type of null as “object”.

object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
// What does the below code print out?
    if (undefined === null) {
        console.log("Moo")
    } else {
        console.log("Zoo")
    }
A

undefined and null are not the same types so === will return false

Zoo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
// What will the below code print out?
    console.log(NaN == "1");
A

NaN equal to ANYTHING is always false, even when compared to itself

False

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