Why is using `eval` considered bad in JavaScript?

View other answers to this thread
Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more

j's photo

as @balajive mentioned.

but ! ;D ... actually a lot of libs do it anyway .... otherwise you can not parse and bootstrap injected script tags for example.

or you could use function http://stackoverflow.com/questions/20129236/creating-functions-dynamically-in-js

but in general don't overuse eval. I try to avoid is as often as I can, but sometimes you need to write selfgenerating code where eval comes in handy.