JavaScript for Developers 17 - Type Coercion and the === operator

preview_player
Показать описание

Learn about how JavaScript sometimes converts types automatically. Also learn how to compare values for equality using the === operator.
Рекомендации по теме
Комментарии
Автор

Hey man! Jus wanna step by and say a HUGE thank you for this series. I'm a devloper with mothertounge Java and some C# experience. I've used JavaScrip like 2-3 years ago a lot during my studies. I'm having a decent understanding of high level programming and OOP and its kind of hard to find such courses geared towards people already developers, with all the superboring basic stuff stripped off, one cant hear anymore :) This course is jus optimal for refreshing JS and is so well structured that its also a lot of fun to go through. Thanks from the heart for your time and effort and for making this free.

harrysanders
Автор

Simply amazing! Really amazed to see that, a trainer of your quality to be this humble. I have seen a lot of trainers, and you are the best trainer I have come across hands down.

udaybhagwat
Автор

Thanks so much Koushik, you made JS and other programming tools more enjoyable and less complicated. I am loving learning more. 🥰

monsterhuntergo
Автор

still helpfull, watchinf after 8 years ♥

safvanp
Автор

love your course. just one thing about this video. as I read in ECMAScript Language Spesifications, the "==" operator actually converts the string into number and then compare them, not the other way around as you said.

unleashedjanebi
Автор

Thank you for explaining in such a simple and intuitive way :)

abarag
Автор

Love your videos!

At 06:29, you say, "it coverts number to a string and then see if those two match". So I wrote this to check if that's true:

var num = 10;
var string = "10.0";
if(num == string) {
console.log("Double equals ok");
} else {
console.log("Double equals not okay");
}

I get "Double equals ok" as the output. so it means the string is converted to a number and then it sees whether they match.
Hopefully, I haven't misunderstood anywhere.

andrewnessin
Автор

Great explanation bro! Breaking into laughter how you brought in explanation of ===

ChandrashekharJani
Автор

when we compare string with number, here as u said in which datatype variables get typecasts

vishalpachpande
Автор

Why convert number to string and not string to number? Are there any priorities?

rehmanmuradali
Автор

Would love to hear reasons for three thumbdowns...

nofyfb
Автор

if javascript does coercion, then why console.log('true' == true) prints false but console.log('1' == 1) prints true?

developerforcloud
Автор

So basically javascript is a crazy language like me.So i like it.2 crazy things can make wise stuff.u never know :D

vmohakrish
Автор

If I was the owner of Javascript I would have change it. I wouldnt care that it would break someones code.
correct is correct and incorrect is incorrect. so if the language has something bad in it that is not correct, . I would have taken it out.
let people correct their own code if their code breaks. As long as the javascript source code is correct the way its suppose to be.
See, this is the problem with humanity & its evolution. We always put a band-aid on everything because we worry about breaking other peoples codes.
even though the source code is damaged and needs correcting. - Javascript owners needs to step up and correct it if the sourcecode is wrong and broken.

RobFos