Hacker News new | ask | show | jobs
by smt88 3219 days ago
This isn't the best solution for whatever is happening to you.

If you don't know what method is going to be called on your class, there's something wrong with your code. I'm assuming this either happens when A) your input isn't validated/sanitized (generic routing allows any method on your class to be called) or B) you're coding sloppily.

In the case of A, you need to validate your routing. If a user calls a route that doesn't exist, they should get a 404. This can become a security issue if you don't do it.

In the case of B, JS already tells you that the method isn't defined. Or, if you're using a good IDE, JSLint, TypeScript, or Flow, you should see a warning before you run your code.

1 comments

This is not intended in any way to be used in a production environment. It is just a cool experiment to show javascript versatility :). Your points are entirely valid!
I don't really believe that. The documentation doesn't mention that it's not meant to be used. It talks about it being used multiple times, and you posted it multiple times.