Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If the value is expected to be a Boolean, use undefined to set it as undefined.

For everything else, use false to “explicitly assign it”, you don’t need a third type.



> use false to “explicitly assign it”

Then you still have null, you’re just spelling it funny while confusing all the other developers who have to deal with your code and making it incompatible with language constructs like the nullish coalescing operator.

If the concept you are trying to express is “null”, then please use null to represent that instead of bringing in a poor substitute like an overloaded false.


No, most likely I'll just use undefined because my abstractions are not a complicated mess that need 2 null types.

Found? string

Not found? undefined


> most likely I'll just use undefined

You were telling people to use false and that’s what I was responding to. That’s why I quoted that part in my comment.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: