JSLint flags any use of the?eval?statement with the message?eval is evil. This is because?eval?is a hook right into the JavaScript compiler. It accepts a string as a parameter and then compiles it and runs it.
Further resources on the evils of eval are available through the above link. Here we are more interested in how?document.write?can equate to?eval
So how can?document.write?possibly equate to being the same? Well, we can demonstrate this with a simple example. You’ll need to set up an HTML page and a JS File with the following code:
2017-07-05
所以說都說盡量不要使用,倒是說一下該怎么安全使用啊。。。
2016-12-16
查了一下資料,只事JS編譯器對代碼編寫過于嚴格,但這種編碼方式是沒問題的。
2016-03-10
2016-02-20
嗯,盡量不要使用eval
2016-01-17
不明所以~同求答案~
2016-01-01
“document.write can be a form of eval.”:“document.write是eval的一種形式”,?eval要盡量避免,是出于安全考慮,因為eval過于強大,他可以把string串作為代碼執行。如果控制不好就會造成安全漏洞。
2015-12-08
同問。
2015-11-17
2015-11-06
“document.write can be a form of eval.”:“document.write是eval的一種形式”,
‘eval is evil.’:“盡量不要使用eval”,
2014-11-18
JSLint flags any use of the?eval?statement with the message?eval is evil. This is because?eval?is a hook right into the JavaScript compiler. It accepts a string as a parameter and then compiles it and runs it.
Further resources on the evils of eval are available through the above link. Here we are more interested in how?document.write?can equate to?eval
So how can?document.write?possibly equate to being the same? Well, we can demonstrate this with a simple example. You’ll need to set up an HTML page and a JS File with the following code: