Can (aᅠ == 1 && a == 2 && ᅠa == 3) equal true?

Karolis Ramanauskas - May 30 '18 - - Dev Community

Here is a JavaScript trivia question. Can the expression (aᅠ == 1 && a == 2 && ᅠa == 3) ever evaluate to true? Well, today I found out it can. Run the below code and see for yourself.

Now let's look at seemingly the same code below. Try to run it. This time the expression does not evaluate to true. So what changed?

The difference is actally really simple and much less mysterious once you figure out what's happening. Apparently, there is a Unicode character called Halfwidth Hangul Filler which is a Korean symbol and is, for all intents and purposes, invisible. So the reason why the first code snippet evaluates to true is because the three variables a are in fact three distinct variables. One of them is prepended with halfwidth hangul filler, another one is left intact and the third one is appended with the hidden character.

Now next time someone asks you whether (aᅠ == 1 && a == 2 && ᅠa == 3) can ever equal to true, you can answer them that yes, indeed it can (with a small caveat) 😀

. . . . .
Terabox Video Player