by berzniz · 12y ago · 0 comments
Not everyone understands why && and || are used outside of if statements. Not everyone knows about joining strings using an array.
This summarises the things you'll have to know to read code in our codebase.
The && though, I've never used in this context. And I'm not sure if I've seen it out in the wild or not. I knew what it did right away so I imagine if I have seen it before I wouldn't remember.
I use the || trick really often, but never the && one.
By the way, why not use a one-liner if instead?
if (condition) something;
I find more readable this way.
Also, for example I use a sublime plugin to automatically tidy my code, and that isn't an option in it, so I don't do it anymore.
What else would you join if not arrays?
You'll probably get a solution using loops and a check if adding a comma is needed or not.
I know, I asked my friends. Ask your new teammates.