I'd suggest being careful about blindly executing javascript this this - at least with your switch statement the input is 'sanitized' in the sense that there's no way for the caller to be sneaky and invoke something other than your matched switch statement values