Which do you prefer? Switch/case, if/else, dispatch table?
Hello, all,
I asked a question in the Javascript forum at SP, just an opinion piece, and thought I'd go ahead and ask it, here, too.
This pertains to Javascript, specifically.
When I first started developing, the only conditional I used was if/else. A few years later, I learned about switch/case and started using it for every conditional that could be done with switch/case, falling back to if/else for situations where switch/case couldn’t be used.
About four years ago, I learned about dispatch tables and I’m going bonkers with it. I would be using dispatch tables in my professional work, but no one else here wants to use them, so I stick to switch/case and if/else just because no one else wants to know about them and I have to keep my code so that anyone can work on it. (heavy sigh).
What is your preference?
V/r,
^ _ ^
PS: An example of a Javascript dispatch table can be found, here.
