开发者

Eval'd behind the scene?

I heard that when I'm doing this:

<a onclick='foo()'></a>

behind the scenes, it generates me an anonymous function, or maybe an eval'd function...? I'm confused, because I do h开发者_如何学Pythonave a function foo, so where is the extra code?

Could I please get some explanation/clarification ?


Yes, it does. It generates an anonymous function, which has body set to what you've enclosed in quotes (so it will call your foo() when executed).

It can be observed when you put a breakpoint in your function and look at the stack trace when it gets hit.

Update

Some illustations: Firebug/Firefox (more Firebug), Chrome

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜