re: Well, the compiled code (if there is such a thing) would be the same, but the denseness does differ a bit. Though whether the default value should ...

Sure. The example is a bit contrived. There would definitely be more error handling logic, as you've mentioned.

Help me understand what you mean by "denseness". From my pov, things look basically the same if you ignore the coding style.

const wow = arg => {
  return (
    animals.hasOwnProperty(arg) && animals[arg]
      || "gimme an animal";


const wow = arg => {
  if(animals.hasOwnProperty(arg)){ //WTF if, who invited you?
    return animals[arg];
  return "gimme an animal";

I’m mostly referring to the fact that it’s a single versus two separate statement/expressions, with the corrolary that the latter allows a line of whitespace inbetween to emphasize them being separate concerns. Moving the second part of the A || B to the next line aids the separation a bit, most people tend to not do that unless the total statement/line is too long to fit.

Edit: thanks for the interesting discussion btw

Ah...ok. Understood. I agree.

edit: Absolutely. That's what this is all about. Thanks for the feedback.

code of conduct - report abuse