javascriptpuzzle

How do two (seemingly!) identical strings not equal each other?


Someone sent me this email:

Why do both of these alert to false?

alert('a‌' == 'a');
alert('a‌' === 'a');

Here's a demo

JSFiddle DEMO


Solution

  • Is this a trick? Did you generate those a's with some special unicode magic? I deleted the a's and re-typed them, and now both alerts show true, as they should

    Updated Fiddle