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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#