JavaScript == VS ===

preview_player
Показать описание
Unlike many programming languages JavaScript has both a double equals (==) and a triple equals (===) equality operator. For the most part these two operators work exactly the same, but the double equals operator converts the types of the objects being compared to the same type. This sounds like a good thing at first, but it can cause some strange bugs to occur when comparing certain objects/types. Because of this the triple equals operator should almost always be used, except in the case of checking if an object is null or undefined.

Twitter:

GitHub:

CodePen:

#JavaScript #WebDevelopment #Programming
Рекомендации по теме
Комментарии
Автор

You may or may not know this but you don't know just how valuable these short one-off, advisory videos actually are to the development community. They are just as valuable, if not more, than a lengthy full-featured tutorial video. Please continue making more!

baatar
Автор

Honestly, you make it easy to understand for those who are not familiar in JS

gmani
Автор

Dope channel! You need a few thousand subs!

developedbyed
Автор

You're getting better with every video dude, good work.

chrisdanikas
Автор

The best video on this topic ever! Concise and well elaborated. Thank you

ericlee
Автор

10 minutes ago, I was asked this question in a mentoring session, And the answer I gave was not up to the mark; Thank-you @Web Dev Simplified, for such simple, yet very useful little information!

SoloWanderer
Автор

haha i spent too long trying to figure this out with google, just to fully understand it a minute into this video. Thanks!

goddamnchampions
Автор

In the ECMAScript spec is clearly stated what == and === difference is.

Basically both == and === identify the type of the variables involved in the comparison, the difference is that == tries to coerce the values to numbers before comparing in case of primitives types and try to coerce to primitives to then try to coerce to numbers in case of non primitive types. === doesn't do any of that it only checks if types are equals if they are not then it returns false.

If you understand your code and the types involved in it it is not necessary to appeal to these mechanic decisions and actually talks very good about your understanding of your code

JassonCordones
Автор

Enjoying your videos, man. What software do you use to record your videos/share your screen? I've been thinking about doing some tutorials myself.

andersonhall
Автор

Kyle should have mentioned the actual terms of == and === because that is where the confusion clears out. A double equals is "abstract" and triple equals is "strict". People who use the abstract equals should be aware of it before using it.

consigiere
Автор

Thank you!!! Didnt make sense until I watched this video

iangunness
Автор

Double equals is also slower due to the type casting

vibonacci
Автор

You are awesome sir
I am watching your tutorial about 2 hours every day to learn and develop my skill
Go ahead

mdosmangani
Автор

thank you !!!! you made it very clear !!! ❤❤❤✨✨✨

shadowrebels
Автор

I'm learning that Javascript does a lot of things behind your back without telling you

Tubeytime
Автор

it's really a great explanation .

rohitdoyal
Автор

2:36 Kyle says we can use == here:
null == undefined
Why do people use the following?
if (val !== null && typeof val !== "undefined")
If Kyle is right, we could simply:
if (val != null)
First code throws an error anyway if val is never declared. And if val is undefined, second code is efficient, condition will be false. Will be true in any other cases, including 0 and "".

szalailaci
Автор

"You need to stop, you need to stop, ..."

deansprivatearchive
Автор

Awesome video. Could you maybe also do a video on what the difference between ' and " are, if there are any? Codacy always tells me, I should use " instead of '

crugg
Автор

A sticker on a chunky cheers mirror send me to this video when I scanned it

void