02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoPrevious Video

Explicit Equality

<p>Sometimes knowing if something is equal just isn't enough and we need to know if it is explicitly equal. This is a fantastic continuation from our <a href="/courses/video/7/198/Comparison-Between-Different-Types.html">last video</a> that explained about matching between different <a href="/courses/video/5/161/Numbers-int-And-unit.html">data types</a>. In this video we'll look into how explicit <a href="/courses/video/7/58/Equality-Operators.html">equality operators</a> work - '===' and '!==='.</p> <p>In the above comparisons, the values were said to be equal even if they are close to each other. But there are situations where we need to check for explicit equality. We want the output to be false even if there is minor difference between the two. The two values must be absolutely equal to satisfy the explicit equality condition. This operator uses the === symbol. Let's recap now: one equal sign (=) is an assignment operator, two equal signs (==) is an <a href="/courses/video/7/58/Equality-Operators.html">equality operator</a> and three equal signs (===) is the Explicit Equality Operator.</p> <h2>Equality Operator (==) and Explicit Equality Operator (===)</h2> <p>Whenever we use the symbol ===, we mean that the comparison should be explicit. For example let us consider a <a href="/courses/video/5/162/Boolean.html">Boolean variable</a> isTrue whose value is true and trace the comparison using <b>trace(isTrue==1)</b>. We know that the best alternative for true is 1. So the application gives the output as true because the equality operator (==) is used for the comparison. But when we use the explicit equality operator (===), the result is totally different. The compiler now wants both the values inside the trace to be absolutely equal. The fact that 'true is equal to 1' is not enough to satisfy the Explicit Equality condition. The result in this case would be false. But if we have <b>trace(isTrue===true)</b> or <b>trace(1===1)</b>, the result would be true for both the cases as the values are explicitly equal.</p> <h2>Inequality Operator (!=) and Explicit Inequality Operator (!==)</h2> <p>The Explicit Inequality Operator works the same as the Inequality Operator but it wants the values to be explicitly unequal, the reverse of the above: we check for inequality rather than equality. Let's see an example to differentiate between (!=) and (!==). If we write <b>trace(isTrue!=1)</b>, the result is false because for normal equality isTrue is considered as 1. But if we write trace(isTrue!==1), the result is true because for explicit equality isTrue is not equal to 1. Therefore, this satisfies the explicit inequality condition and hence, we can expect the result as true.</p> <p>Don't get confused with these four different types of operators. To sum up, you can remember the following points and avoid confusion. == and != checks for equality and inequality respectively but consider the closest value as well during comparison. === and !== checks for explicit <a href="/courses/video/7/55/Equality.html">equality</a> and explicit inequality respectively and the comparison requires the values to be absolutely equal or absolutely unequal.</p>

Overview

What are operators and why do we need them to create programs. We'll discuss various types of operators and their uses later in this course

01:49

Default Values

To understand operators, we first need to understand how variables work -- mainly when it comes to default values and why they differ for various variable types.

06:41

Equality

In this video we will compare between equality and assignment and learn how to work with both. We also differentiate between the assignment operator (=) and the equality operator (==)

06:40

Rational Operators

In this video we will see how to check if a variable is: bigger, smaller, greater or equals, smaller or equals and so on..... using rational operators

05:52

From Rational to Boolean

All the operators we worked with so far returned in our trace panel a value of true or false. In this video we'll see that connection of our operators results to the Boolean data type as we explore

05:26

Equality Operators

So far we've seen how to compare and see if values differ or match but we did not have a way to ask if not. In this sample we'll look into the equality operator(make it a bit more complex)

05:59

Comparison Between Different Types

In the heart of programming is the capability to compare between things. In this video we talk about comparing between different variable data types.

04:15

Explicit Equality

Sometimes knowing if something is equal just isn't enough and we need to know if it is explicitly equal and that's where explicit equality operator comes in...

08:05

Logical Operator

Logical operators enable us to compare a few things at a time such as AND, OR and NOT. We will learn the syntax to represent these operators using few examples

09:52

There Are Many Ways To Say No

doing exactly the oposite of the logical logic seams crazy but actually its a very great way to get things done. Let us learn how to say no in terms of programming

04:15

Null vs. Undefined

Why are there two ways of saying nothing? I ponder that as well as I try to explain their roles. In the process, we will learn the syntax and its application in code

06:20