I came across a technique for
conditionally calling one function or another, on the same argument passed to whichever function
.
Here's the snippet:
The value of
(x ? alert : prompt) ('hi')The value of
x determines whether alert('hi') or prompt('hi') will be called. Both functions are passed with ('hi').
I hope you'll find this snippet useful when you need to