|
|
|
|
|
by stephen82
2928 days ago
|
|
Of course this would not work. typeof(true) is of type 'Boolean' and typeof(1) is of type 'number'. Do they compare to the same type? Nope, therefore is false in both cases. Try the following: let foo = true;
true === foo === true; // returns true.
|
|
You might mean it shouldn't work? but alas it does (because of 'lopsided equality tables'). Try the following: open the console of your browser, type the following:
true == 1 === true
and press enter - tada! You can also check out this SO answer if you are sufficiently flabbergasted: https://stackoverflow.com/a/12236341