Lesson, Computers aren't that smart


#1

When you are told to debug the code, if you forget to set the conditional in the if loop to == it will remind you, but it will incorrectly state that it needs to be ===. This might confuse other users.


#2

We have to expect some confusion at this stage. When everything is new, even a little thing can require a larger explanation.

You have me at a loss here, though, since I do not know the lesson to which you refer. Perhaps a link will help get me on the correct bearing. Please post.


#3

Well I was slightly wrong, I'm used to using == to check a conditional, but === works too. I feel like both methods should be shown as they both work but I can see now that the post wasn't wrong, I just didn't realize both methods would work.


#4

You will find that both work in some instances, but not all.

a == b

This is an equality. Consider it in the light of a and b being expressions.

Expressions yield a value and the type is determined, thereupon. An equality expression, as the above is also known, does not depend upon the operands yielding the same data type.

1 == '1'    =>  true

JavaScript sees that they look the same. That's equality. Now let's look at identity. That is where the triple equals sign comes into play. In order for something to share an identity with something else, it has to be exactly the same. Both data and data type must equate.

console.log(1 === '1');   //  false

var s = "ONE";
console.log(s === "ONE"); //  true