# Equal Sign Operators Concept By Digital Marketing Company in Kolkata

Sumit

Let's talk about comparison operators and Forgan going any further I did want to discuss this. Double equals versus triple equals issue. So this is actually very important to know when you're doing comparisons with the difference between them double the triple equal sign as we've seen. This is valid javascript this works or Linter is kind of warning us but doesn't really say why. The digital marketing company in Kolkata teaches the functions of variables as well.

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.

Topic 1:-

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.

That's something you need to be aware of is that javascript will occasionally do type conversions for you and you may not be expecting that. On the other hand, the triple equal sign does not do any type of conversion it just checks if two values are the same type. If so do they have the same value.

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.

Topic 2:-

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.

Topic 3:-

Now it's telling us that it's true right. So what's happening is that javascript is converting the number five into a string for us. It just assumes that that's what we wanted to do it seems that's what we intended. This may or may not be what you intended. Right, you may be trying to compare digital marketing company in Kolkata equal sign operators.

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.

Let's try to add these together and you might expect this to add up to but actually, javascript is assuming and you let me get rid of these for a console log here. So it gives us and you're opening. Well, that's weird. Why would it give us we're adding and five together. The reason is it's converting this constant into a string and it's basically concatenating these strings together.

Topic 4:-

So it's the same as saying you know Konst high equals high plus conc something equals another string you add them together and it concatenates the string together. This is something that's built in the javascript which digital marketing company in Kolkata teaches, it does this kind of type conversion for you which is usually pretty nice but can be frustrating if it doesn't have the effect that you intended.

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.

Conclusion:-

Right. So you know if you did a different number here let's see what happens. This is always false. But again if you take this it's going to convert it to a string and then evaluate it to true. Right so it may not have the effect that you want and there are of course methods built into javascript to do this kind of simple conversions.

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.

So here we just explicitly told javascript what to do. In my experience, it's always better to be super explicit in telling your code whether it's javascript or any other coding language. Be explicit in what you want it to do. So here we take the five converted into a number and now it has a behavior we might expect.