What are some really good real world examples for this? (3,4 examples).
Wouldn't the optional operator be enough?
functionfoo(bar?:string){if(!bar){// handle if bar is falsy}// do stuff if value not falsy.}
The only thing I can think of is when you really need the parameter to be exactly null. But I never have this use case in the projects I work on, so I think something is fishy :))
Actually it's just personal preference to have null values instead of undefined.
The example I provided is actually not that great, because I tend to use this more with objects and their properties.
I’m a developer that do web applications by day, and games by night. I work with Typescript every day, using tools like Angular and React. In this post I like to write about my experiences with those.
The difference between the two, is that in Maybe the value is required, and in the second one is optional. So, you can have Maybe values and those values would be either defined or not, but would still be required. I have found this to be useful in React.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What are some really good real world examples for this? (3,4 examples).
Wouldn't the optional operator be enough?
The only thing I can think of is when you really need the parameter to be exactly
null
. But I never have this use case in the projects I work on, so I think something is fishy :))Actually it's just personal preference to have null values instead of undefined.
The example I provided is actually not that great, because I tend to use this more with objects and their properties.
The difference between the two, is that in Maybe the value is required, and in the second one is optional. So, you can have Maybe values and those values would be either defined or not, but would still be required. I have found this to be useful in React.