"!!" should be pretty obvious to any javascript developer.
Re:Advice on JSX Conditionals
by 9wzYQbTYsAIc on Wednesday March 09, 2022 @02:18PM
(#30618793)
Nonetheless, better for the industry if we start to embrace more uniformity in our idioms.
You can practically copy-and-paste between JavaScript and C# these days, with some trivial text replacement tweaks, if you are careful with your idioms.
What if you wanted to get the boolean value of number but with not.
Would you write: !Boolean(n)
Or would you write: !n
Re:Advice on JSX Conditionals
by 9wzYQbTYsAIc on Wednesday March 09, 2022 @02:50PM
(#30619150)
if it were C#, I’d write it along the lines of !(n as bool), but for the purposes of JS, I suppose something like:
const IsNumber = (value) => Boolean(value);
!IsNumber(n)
I’m not a fan of using the return-type as the function name, especially when you are really just trying to find out if something is a number.
Re:Advice on JSX Conditionals
by dbetteridge on Wednesday March 09, 2022 @03:48PM
(#30619743)
It might be, but not everyone knows js and I don't expect future people to be me.
More obvious and more readable is always better
Its more obvious what it achieves just at a glance.