News for hackers. Stuff that matters.
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.

Re:Advice on JSX Conditionals by postalrat on Wednesday March 09, 2022 @02:43PM (#30619063)
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.