Current CTO exploring entrepreneurship on the side; coach; mentor; instructor.
Dedicated to promoting digital literacy and ideological diversity in tech.
In this particular case, the if is redundant, as the condition for your if is the same as your return content.
You could simply return everything between the brackets of your if instead of explicitly returning true.
The above is important because the way you've written actually makes your application harder to read because it increases what's called "Cyclomatic Complexity" by introducing a fork in your execution path.
Other than that, "the syntantic sugar" of Javascript (arrow functions and the like) are not something I like either. What you're seeing is the proloferarion of the "Code Golf" fallacy. While a fun thought experiment, it is often a measurably worse way to write software thay needs to be maintained by other people.
Current CTO exploring entrepreneurship on the side; coach; mentor; instructor.
Dedicated to promoting digital literacy and ideological diversity in tech.
In this particular case, the if is redundant, as the condition for your if is the same as your return content.
You could simply return everything between the brackets of your if instead of explicitly returning true.
The above is important because the way you've written actually makes your application harder to read because it increases what's called "Cyclomatic Complexity" by introducing a fork in your execution path.
Other than that, "the syntantic sugar" of Javascript (arrow functions and the like) are not something I like either. What you're seeing is the proloferarion of the "Code Golf" fallacy. While a fun thought experiment, it is often a measurably worse way to write software thay needs to be maintained by other people.
I'm not entirely sure I follow, how would that look?
I do agree in principle though re: complexity. I could have spent some more time on my counter examples for sure.
Oh woops!
I've misinterpreted what this is doing; I thought I saw an else statement in your if.
That's definitely my bad -- ignore my comments about Cyclomatic Complexity. They don't apply here.
Roger that, I thought you had some extra magic in store there and got way intrigued : )