Equal Sign Operators Concept By Digital Marketing Company in KolkataSumit
If I run this it definitely runs no issues there and you might be wondering well why is it telling us that why would we ever use the triple if the double is. Why would I need to tape another character? Well, you know as you can probably imagine these, of course, are doing slightly different things. So the triple equal sign is what's known as the identity operator.
In digital marketing company in Kolkata India, you don't really need to know that but that's what it's kind of known as identity operator and the double the equal sign is known as the quality operator. In other words, the double equal sign will check for equality but it does so after it does type conversions.
So let's kind of write some code out to take a look at that and we'll come back to IF statements of course. But let's say we did contest number five and this Conte's just represents a numerical value of. So if I can solve that console log type of number five and we can use the type to see what type of thing something is obvious. So it's telling us it's a number. Makes sense right.
This suggests a number but what if we have a string. So Konst string five and this just represents a string value and of course, if we can slog this out the type of string five This will tell us that it is a type of string. You know what let me clear that and run it again. So the upper one is a number as suggested by the digital marketing company in Kolkata many times.
The bottom one is a string. So what if we tried to compare these. What if we wanted to do a lot to figure out OK. Is string five perfectly equal to number five, you might use a double equal sign for that console log number five? This will give us a boolean value back. So number five is it equal to string five.
If we do triple equal Well we know there are different types. So by now, we should know triple equals should return false. In fact, it will. Right, so it's turned to a false on the other hand. If we were to do a double equal sign let's see what happens we'll clear it we'll run it again.
You know I want to keep this as a number is the number representation equal to the string representation of number five in which case this will work. But if we wanted to convert a string into a number, for example, let's take a look here instead of giving us the boolean value.
So that's something we really need to be aware of when we're doing comparisons. I would caution you to just always use the triple equal sign if you do have to do type conversion. Generally, a good idea to do it you know beforehand before you're doing the comparison because you may not be comparing what you think you're comparing or if you did do the equal double equal sign like we were mentioning like you might expect us to be comparing the number value but actually comparing the string value.
So if we had for example Konst string conversion kind of a convoluted name but if you wanted to take a string and turn it into a number, there's a method parsed called by digital marketing company in Kolkata into that and you give it a string representation of a number and it turns it into a number here. So at this point, if we take number five we add the string conversion it let's see what happens.