TL:DR :
Most of the time out javascript code becomes clumsier if we inserted the multiple null checks for the several entities. Those ch...
For further actions, you may consider blocking this person and/or reporting abuse
Good article!
I appreciate how you built up to the (in my opinion) most useful forms of null-checking, the
?.
and??
operators. Coming from a .NET background, I use this pattern frequently, so it's good to know that I can apply the same pattern in JavaScript.Thanks for sharing :)
Greatful for your feedback !
I like this post very much, especially the "?. with ??" thing, which I didn't know before. Is there any similar thing for use with the bracket-syntax (like for
person[itsName][myHobby]
)?Great job compiling this list!
Just want to point out the word
operator
in the title is misleading. There is only one nullish coalescing operator that is??
. These are all great ways to handle nullishness, but they are not all "operators".Cheers!
Thanks :)
Great post. My personal preference would be to use .some() instead of .includes() as it will return early as soon as it resolves true, where .includes() will go through every item in the array when it probably doesn't need to. I would also agree that nested ternary is very hard to read so I would probably avoid that if I had to nest multiple conditions and just fall back to good old fashioned if/else.
But this is really useful, thank you.
Thanks for your feedback !
Good post but I don't agree that multiple ternary operators is a good idea. There even is a lint rule to prevent that. In my opinions it makes code harder to follow that if-else
Thanks for you feedback !
but, I think It is preferential to whether or not we should use this kind of stuff !
I will definitely look into that !
Super intuitive and neat.
😇
I knew (and use) two of these but didn't know about default assignment and includes. That could come in handy! Thanks! :)
Thanks !