V8 actually has two JIT compillation modes exactly because of things like this. One handles "easy" functions and the other handles "hard" functions (functions that contain eval or try and catch for example), the "easy" compiller has worse performance. This link explains it well:
https://github.com/petkaantono...
Great read for people who want to optimize for V8, many of the tips should be valid for other javascript engines as well.
From the article:
Currently not optimizable (ie will use the slower compilation method):
Generator functions
Functions that contain a for-of statement
Functions that contain a try-catch statement
Functions that contain a try-finally statement
Functions that contain a compound let assignment
Functions that contain a compound const assignment
Functions that contain object literals that contain __proto__ , or get or set declarations.
Likely never optimizable:
Functions that contain a debugger statement
Functions that call literally eval()
Functions that contain a with statement