Equivalent to (=) is a task administrator, which sets the variable on the left of the = to the worth of the articulation that is to its right side. This administrator doles out lvalue to rvalue.
For instance, Writing a=10 is fine. In the event that we compose 10=10, 'a' = 10 or 'a' = 'a', it will bring about a reference blunder.
Twofold equivalents (==) is an examination administrator, which changes the operands having a similar kind before correlation.
The fundamental task administrator is =, that doles out the worth of one operand to another. That is, a = b doles out the worth of b to a.
The == administrator is a correspondence administrator. It checks if its two operands are something very similar by changing articulation from one information type to other people. You can utilize == administrator to think about the personality of two operands despite the fact that, they are not of a comparable sort.
How === Works Exactly?
- Severe equity === watches that two qualities are something very similar or not.
- Worth are not certainly changed over to some other worth before correlation.
- Assuming the variable qualities are of various kinds, the qualities are considered as inconsistent.
- On the off chance that the variable are of a similar sort, are not numeric, and have a similar worth, they are considered as equivalent.
- In conclusion, If both variable qualities are numbers, they are viewed as equivalent if both are not NaN (Not a Number) and are a similar worth.
Example of =
In the underneath program, there are two factors "a" and "b". We are adding and printing their qualities utilizing a third factor, "c". The amount of the worth of variable "a" and "b" is 7. Thusly, the yield is 7.
Example of ==
In the below program, we have declared one variable "a" having value 10. Lastly, the statement a == 20 returns false as the value of a is 10.
<!DOCTYPE html> <html> <body> <p id="demonstration"></p> <script> var a = 10; document.getElementById("demonstration").innerHTML = (a == 20); </script> </body> </html>
Example of ===
In the below program, the value of variable x is 10. It is compared to 10 written in double-quotes, which is considered as a string, and therefore, the values are not strictly the same. The output of the program is false.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var x = 10; document.getElementById("demo").innerHTML = (x === "10"); </script> </body> </html>
- = is used for assigning values to a variable, == is used for comparing two variables, but it ignores the datatype of variable whereas === is used for comparing two variables, but this operator also checks datatype and compares two values.
- = is called as assignment operator, == is called as comparison operator whereas It is also called as comparison operator.
- = does not return true or false, == Return true only if the two operands are equal while === returns true only if both values and data types are the same for the two variables.