DEV Community

Discussion on: Clean JavaScript - 10 Tips

Collapse
coly010 profile image
Colum Ferry Author

I think we'll agree to disagree on the usage of arrays. For example, you are using some similar to how I describe where we check an array to see if the condition matches, albeit I state to place the results of conditionals into the array.

As for your isEqual function. That does not look friendly and any junior Dev coming along afterwards will be confused very easily.

The reasoning behind using the array for conditionals stems from situations where we aren't in control of the data model, and yes that can happen, due to time restrictions and due to working on legacy codebases or codebases that have had a lot of employees come and go with little documentation, where product tack new features on without sparing time to handle technical debt.

Collapse
macsikora profile image
Pragmatic Maciej

The thing is that it doesn't hep in any way in terms of not controlling the data model, you have trouble if u do that by array or not. My examples of using .some show what I am able to accept in the code, but this examples also do not make any difference in terms of the code quality.

There is no, even single reason to change multi-conditions into multi-array of conditions. I disagree hard here because you have "Clean JavaScript" article title. This is not more clean, but alternative way of doing conditions. If I would see such in the code my first question would be - "Why?". And the only answer I see is - "Because I can"

PS. in terms of isEqual I agree, it is subjective, as point-free not always makes the code better.