Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 2
    +1 for pointing out this wide-spread attitude (does not necessarily apply to the OP): "Just because you're using the latest ES6 techniques or using the most popular programming paradigm doesn't necessarily mean that your code is more correct, or that junior's code is wrong.". Commented Jun 10, 2017 at 8:24
  • +1. Just a small pedantic remark, you can use the spread (...) operator instead of _.concat to remove that dependency. Commented Jun 11, 2017 at 5:10
  • 1
    @YoTengoUnLCD Ah, good catch. Now you know that me and my team are still on the journey of unlearning some of our lodash use. That code can use spread operator, or even [].concat() if one wants to keep the shape of the code intact. Commented Jun 11, 2017 at 9:15
  • Sorry, but this code listing is still much less obvious to me than the original "junior code" in OP's post. Basically: Never use ternary operator if you can avoid it. It's too tense. In a "real" functional language, if-statements would be expressions and not statements, and therefore more readable. Commented Jun 12, 2017 at 20:15
  • @OlleHärstedt Umm, that's an interesting claim you made. The thing is, Functional Programming paradigm, or any paradigm out there, is never tied down to any particular "real" functional language, much less its syntax. Thus, dictating what conditional constructs should be or should "never" be used just doesn't make any sense. A ternary operator is as valid as a regular if statement, whether you like it or not. The readability debate between if-else and ?: camp is never-ending, so I won't get into it. All I will say is, with trained eyes, lines like these are hardly "too tense". Commented Jun 13, 2017 at 16:51