When using JavaScript before, I would occasionally encounter the use of the two symbols == and === to determine whether the two variables are equal. However, the difference between these two symbols has not been investigated. I encountered the symbol === again today, so I decided to check it out what the difference is.
There are two comparison characters "==" and "==" in Javascript," so what is the difference?
1. For basic types such as string, number, there is a difference between == and ===
1) Comparison between different types, == Comparison of "converted into the same type" to see if the "value" is equal. === If the types are different, the result is different
2) Comparison of the same type, directly compare the "value" and the results of the two are the same
2. For advanced types such as Array, Object, there is no difference between == and ===
When a variable is defined as Arrary and a variable is defined as Object type, but its value is the same, the result of comparison of == and === is the same because it is a "pointer address" comparison
3. There is a difference between basic types and advanced types == and ===
1) For ==, convert advanced into basic types and perform "value" comparison
2) Because the types are different, the result === is false