Created
April 18, 2010 19:20
-
-
Save lukaszkorecki/370488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| new Boolean(null) | |
| // => false | |
| typeof false; | |
| // => "boolean" | |
| typeof new Boolean(null) | |
| // => "object" | |
| // Obviously: | |
| false == new Boolean(null) | |
| // => true | |
| false === new Boolean(null) | |
| // => false | |
| // Best way (probably faster as well): | |
| !!null | |
| // => false | |
| !!null === false | |
| // => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Można się zdziwić czasami - to prawda. Rozchodzi się o to, żeby sprawdzać dokładnie typy. Choć w wypadku kiedy możemy dostać booleana albo obiekt Boolean, to trzeba by jakoś to inaczej kontrolować. Swoją drogą prototype nie ma może metod do sprawdzania tych "pseudotypów"? Bo o ile przypadek z Booleanem byłby dosyć abstrakcyjny, to ze Stringiem może już być różnie.
Cóż... Nic nie jest idealne ;)