Couldn’t you just do cmd.run || cmd.fire || cmd.execute || cmd.callback ? I’m not super familiar with js. Worked with it a bit, but still not great, so please correct me if I’m wrong.
Yep that would work. JavaScript (and many others) implement what's called Short Circuit Conditionals or Lazy Evaluation, which is a fancy way of saying that if you're checking for multiple things inside an If statement (or just checking for condition in general) if the first check makes the statement true it won't bother checking the rest.
So once cmd.run gets executed, it'll skip the remaining ones. But if cmd.run can't be found, it moves onto trying cmd.fire instead.
166
u/Koala_King_ Apr 22 '21
Couldn’t you just do
cmd.run || cmd.fire || cmd.execute || cmd.callback? I’m not super familiar with js. Worked with it a bit, but still not great, so please correct me if I’m wrong.