Hacker News new | past | comments | ask | show | jobs | submit login
Why is there a 'null' value in JavaScript? (stackoverflow.com)
3 points by hackathons2 on Aug 6, 2019 | hide | past | favorite | 1 comment



> I think that your conclusion that JavaScript defines undefined as "there is no such property" and null as "the property has no value" is perfectly correct.

This answers a puzzling irk I had with TypeScript where name?: <type> could have a valid value of <type> or undefined rather than what I'd expect to be null or a non-null valid value of <type>. If I consider that 'name' is a property of the containing object then undefined makes sense in context. It is annoying to say <type> | null | undefined though.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: