Mik*_*ium 8 google-chrome eval function
为什么Chrome会抛出
SyntaxError: Unexpected token (
Run Code Online (Sandbox Code Playgroud)
当我试着打电话时:
eval("function(){alert('test')}")
Run Code Online (Sandbox Code Playgroud)
?
zel*_*lio 10
Chrome正在抛出SyntaxError,因为您需要在函数周围使用()或者需要命名它.
//This defines a as the function
eval("function a(){alert('foo')}");
//This returns the anonymous function
eval("(function(){alert('foo')})");
Run Code Online (Sandbox Code Playgroud)
要么应该正常工作.
| 归档时间: |
|
| 查看次数: |
3034 次 |
| 最近记录: |