using functions to `case` match in `switch` statements
I've never seen this used, however, I was pondering the feasibility of using a switch
statement where each case
match executes a function instead of simply matching on a static value.
This is best explained by viewing the gist example: https://gist.github.com/4217094
I doubt it would be more/less performant than using if
/else
, however, I like the cleanliness of it, especially if, like me, you don't like excessive use of braces...
Written by christos constandinou
Related protips
2 Responses
That's interesting, thanks for sharing!
over 1 year ago
·
np. :^)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#