Why does eval() exist?

后端 未结 6 796
执笔经年
执笔经年 2020-12-09 01:49

Many programmers say it is a bad practice to use the eval() function:

When is JavaScript's eval() not evil?

6条回答
  •  温柔的废话
    2020-12-09 02:24

    Because sometimes there is a need. All the same reasons for/against using eval in JavaScript can likely be shared with the use of reflection in Java, for example.

    However, I agree with everything you quoted in your question. Many reasons for using it are ill-advised, and best done differently - but sometimes, there is still a need, or it is simply the "best choice" over other available alternatives. (I'd focus on the answers to Is there ever a good reason to use eval()? for additional reasons.)

    +1 to your question for good research.

提交回复
热议问题