Why do people say that javascript eval() is evil but you get no objections against setTimeout and setInterval etc?

心已入冬 提交于 2019-11-29 06:11:13

I'd say you hear the same objections. setTimeout (with string and not function parameters) is pretty much the same as eval.

If possible,

 setTimeout(function(){ alert ("hey") ; }, 1000);

Because when people say "eval", they mean "eval and any function that is more or less equivalent to eval", but the former is much shorter to say. So the answer to your question is yes, it is as risky.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!