Skip to content

Comment on JS performance: try / catch versus checking for undefined parent

Comments

I suspect the technical reason is because it hasn't been aggressively optimised. The reason for that is probably that it's not widely used in the real world, or at least not in performance-critical code. Especially in very tight code like that, I don't think there's a fundamental reason why the compiler couldn't detect the single throw site and compile the code down to the same as the conditional. It gets a bit messier when cascading an exception down the call stack.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.