Eval'd behind the scene?
Eval'd behind the scene?
我听说当我这样做的时候:
<a onclick='foo()'></a>
在幕后,它生成了一个匿名函数,或者可能是一个eval函数…?我很困惑,因为我有一个函数foo
,那么额外的代码在哪里?
我可以得到一些解释/澄清吗?
是的。它生成一个匿名函数,该函数的主体设置为您在引号中包含的内容(因此它将在执行时调用您的foo()
)。
当你在函数中放置一个断点,并在它被击中时查看堆栈跟踪时,可以观察到它。
一些例子:Firebug/Firefox(更多Firebug), Chrome
相关文章:
- Intercept the cellSubmit jqGrid
- CSS中的游标属性似乎不适用于USB On The Go
- Appending the innerhtml of <th>
- jquery in the middle of html
- Can't get the tail to wag (animate) in three.js?
- jquery.proxy in the bootstrap-typeahead.js context
- What is the difference between `HTMLImports.whenReady` and `
- confuse about the parentNode
- momentjs toISOString without the "z"
- toDataURL(), from the Web onto my Computer
- JavaScript Get the child id
- jquery insert-before to text in the same DOM
- JQuery DataPicker add on the
- jQuery: setInterval effects on the server?
- gulp-concat twice the content
- What type is the 'return' keyword?
- Change the title on click of <li>
- DataTables-FixedHeader-多个tr in the ad对齐问题
- What is the reason for cloning the listeners array in nodejs
- Eval'd behind the scene?