6. Operators Flashcards

Equality Operators, Loose Operator , Strict Operator, Logical Operator

1
Q

Symbol for Equality Operator ?

A

=== (is an strict equality operator)

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

Example for Strict Operator (Reveal Answer )

A
let age = 18
if (age === 18) console.log('You have become an adult');

In the above example using the if statement ( if we get the exact value then it will show the output in the console else it will not show anything);

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

Symbol for Loose Operator ?

A

== (is an loose operator)

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

Example for Loose Operator (Reveal Answer )

A
let kiranage = '18'
if (kiranage == 18) console.log("I understood the concept");

Here in the above example now since == is a loose operator it will convert string to a number and will match and will show the output.

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

Which Operator can convert any string or values ?

A

== (loose operator) (can convert any string or values)

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

Which operator matches the exact value without which the code will not be executed ?

A

=== (strict operator)

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

Symbol for AND Operator ?

A

&&

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

Symbol fro NOT Operator

A

||

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

Symbol for NOT Operator

A

!

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

Example for AND Operator

Reveal Answer

A
const hasDriversLicense = true //A
const hasGoodVision = true //B

console.log(hasDriversLicense && hasGoodVision)

Because ( true + true = True ) as per the Boolean logic table.

Example 2
const hasDriversLicense = true //A
const hasGoodVision = false //B

console.log(hasDriversLicense && hasGoodVision);
Output = false
Explanation :- true + false = false ( if any one is false then it will be false )

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

Example for OR Operator (||)

Reveal Answer

A
const hasDriversLicense = true //A
const hasGoodVision = false //B

console.log(hasDriversLicense || hasGoodVision);
Output :- true

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

Example of NOT OPERATOR (!)

Reveal Answer

A
const hasDriversLicense = true //A
const hasGoodVision = false //B

console.log(!hasDriversLicense);

Explanation :- true + false = false ( if any one is false then it will be false )

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