Re:Using Dispatch Tables to Avoid Conditionals in JavaScript
by jcampbell1 on Monday May 13, 2013 @12:11PM
(#5699498)
You have to be careful when doing this type of stuff. For instance, the switch case is actually doing both validation and switching, where as the dispatch table does no validation.
Consider:
processUserInput('toString');
That has very different behavior in the two different styles.
Consider: processUserInput('toString');
That has very different behavior in the two different styles.