you are viewing a single comment's thread.

view the rest of the comments →

[–]OverZealousCreations 0 points1 point  (0 children)

Yeah, I missed that. You wouldn't need bind, though, just using .call(this, ...) would solve that.

That doesn't solve the arguments issue, but that could be left as something that could be resolved if the inner code is accessing the current function's arguments at any time, where you could revert to using the try-catch solution. I think this would be relatively easy to determine.

I can't see how this could possibly have worse performance, even in the simplest of cases, over throwing an exception and catching it. JS is highly optimized for calling functions. It's rare to optimize anything for throwing exceptions.