English 中文(简体)
何时评价“这”?
原标题:When is "this" evaluated?

下面的法典

a.b = function c(){
    return function e(){
        return this;
    };
};
d = a.b();

d(d)的价值如何? 这可能不是一个很好的例子,但我只是混淆了“这”指的是什么。

感谢

问题回答

既然现在就等于是《联合国公报》,那么“这”将评价它所称的任何职能。 至今尚未进行过实际评估。

执行工作结束时,<代码>d=功能 e(){交接;} ,因此,<代码>d(><>>/code>> 时,将评价<编码>。

你们的法典与“这”并不相同。 d) 职能e,因为你将职能称为“(b)”的回报值,从而恢复职能。

d = function e(){
    return this;
}

现在,<代码>该的价值取决于你在指定这一职能时如何评价<代码>该<>。 如果您仅将其称作d(>>>>>>,则即为全球<代码>。 反对。

如果我有的话,请说

obj ={foo:1, bar:2};

我也这样说。

d.call( obj )

http://www.un.org。 电话(电话)方法用于在任何物体上指定一个功能,即该功能内的密码(<>ts)。

I know Javascript this is really confusing and it isn t easy to get your head around it. May be this can help http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx

<代码>该是所有职能的隐含参数。

apply 电话

If you know python, this is just like self, but not explicitly written and always there

这通常是指职务的召集人。

$( .image ).each(function(index){
    alert($(this).attr( href ));
}

I think a.b() will return a

http://remysharp.com/2007/04/12/jquerys-this-demystised/"rel=“nofollow”http://remysharp.com/2007/04/12/jquerys-this-demysted/

this is a reference to the object on which method was called. d() is similar window.d() (if there is no with instruction)

假设<代码>d(>,在您的上行之后立即打电话到d(<>>/code>,将全球物体退回:window。 如果你重新坐在浏览器上的话。

然而,这两种情况都是真实的:

d.call(a) === a;
d.call(a.b.prototype) === a.b.prototype;

也就是说,this is defined by what is adopted in as the first debate to calls/code>。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.