Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: jQuery Quer...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 17 of 21 Topic 36376 of 37484
Post > Topic >>

Re: jQuery Query about comparing jQuery references

by dhtml <dhtmlkitchen@[EMAIL PROTECTED] > Jul 26, 2008 at 10:25 AM

On Jul 26, 4:01=A0am, Thomas 'PointedEars' Lahn <PointedE...@[EMAIL PROTECTED]
>
wrote:
> dhtml wrote:
> > Thomas 'PointedEars' Lahn wrote:
> >> dhtml wrote:
> >>> Thomas 'PointedEars' Lahn wrote:
> > The identifier "window" should be the same object as the thisArg,
> > regardless. Where the object is found in the scope chain would not
matt=
er
> > (at least in terms of the expected behavior for the language).
>
> There is no public standard to back up your claims.
>

The Ecma-262 spec, Entering An Execution Context, for Function Code.

| 10.2.3 Function Code
=2E..
| The caller provides the this value.


| 10.1.7 This
| There is a this value associated with every active execution
context.
| The this value depends on the caller

> >> Then you call a foo() function as the method of an object in the
scope
> >> chain.
>
> >> It is not logical to assume that you would be calling the same method
> >> on the same object, and it is therefore not logical to assume that
> >> `window' and `this' in the method's local execution context refer to
> >> the same object.
>
> > The window property of the global object is the global object itself.
>
> There is no public standard to back up your claims.
>

The Ecma-262 spec, again.

| 10.1.5 Global Object
| There is a unique global object (15.1), which is created
| before control enters any execution context.
=2E..
| in the HTML do***ent object model the window property of
| the global object is the global object itself.
http://bclary.com/2004/11/07/#a-10.2.3


> > If the - this - value is not the global object, then what is - this -?
>
> It could be the Global Object which were a different object than the one
> referred to with `window'.
>

window is the global object.

> > Calling the foo method with call() or apply results in the expected
> > behavior:-
>
> > foo.call(null);
> > foo.call((function(){return this;})());
> > foo.call(window);
> > foo.apply((function(){return eval('this');})());
> > foo.call(eval('window'));
> > foo.call((function(){var window;return window;})()); // undefined
> > foo.apply((function(){ return eval('(function(){return this;})();');
})=
());
> > "true, true"
>
> > The thisArg is always the global object.
>
> You cannot be sure.

In all of the above, the thisArg will be the global object. For some
cases, it will be due to the fact that call() or apply with the first
argument being null or undefined, the global object will be the this
arg. In the third case, the window alias is passed in as the thisArg:-
foo.call(window);

| 15.3.4.4  Function.prototype.call
|   The call method takes one or more arguments, thisArg and
| (optionally) arg1, arg2 etc, and performs a function call
| using the [[Call]] property of the object. If the object does
| not have a [[Call]] property, a TypeError exception is thrown.
| The called function is passed arg1, arg2, etc. as the arguments.
|
|  If thisArg is null or undefined, the called function is passed
| the global object as the this value.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Lets look at how [[Call]] works.

| 13.2.1 [[Call]]
| When the [[Call]] property for a Function object F is called,
| the following steps are taken:

| 1. Establish a new execution context using F's FormalParameterList,
| the passed arguments list, and the this value as described in
10.2.3.

f.call is resolved on Function.prototype. Function.prototype.call is
called with the thisArg as foo. call() performs a function call using
foo's [[Call]] property and using the global object as the thisArg.

>
> > So it seems to be one of the following: 1) =3D=3D operator has special
> > behavior with the window/global object in JScript, for which further
> > explanation is warrented, or 2) the window object is recreated in the
> > execution of a function call.
>
> > 1 - An undesirable behavior; possibly a bug (as in "unintended,
> > undesiarable behavior", not "spec violation")
> > 2 - A violation of the spec
>
> 3 - a standards compliant deviation from your unfounded expectations.
>

It is not exactly clear what is going on with the window vs the
thisArg of a function executing in global context. There is no reason
to believe that this is standards compliant.


Garrett

> PointedEars
 




 21 Posts in Topic:
jQuery Query about comparing jQuery references
"Aaron Gray" &l  2008-07-25 15:41:15 
Re: jQuery Query about comparing jQuery references
Henry <rcornford@[EMAI  2008-07-25 08:17:11 
Re: jQuery Query about comparing jQuery references
"Aaron Gray" &l  2008-07-25 19:08:52 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-25 22:56:56 
Re: jQuery Query about comparing jQuery references
"Aaron Gray" &l  2008-07-25 23:00:58 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 00:25:30 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 00:19:13 
Re: jQuery Query about comparing jQuery references
"Aaron Gray" &l  2008-07-25 23:48:02 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-25 11:45:01 
Re: jQuery Query about comparing jQuery references
"Aaron Gray" &l  2008-07-25 20:38:31 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-25 16:50:30 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 03:17:53 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-25 18:39:34 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 04:25:49 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-26 00:23:39 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 13:01:51 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-26 10:25:29 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-26 21:32:17 
Re: jQuery Query about comparing jQuery references
dhtml <dhtmlkitchen@[E  2008-07-26 16:16:25 
Re: jQuery Query about comparing jQuery references
Thomas 'PointedEars' Lahn  2008-07-27 14:51:21 
Re: jQuery Query about comparing jQuery references
Lasse Reichstein Nielsen   2008-07-27 15:53:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 11:17:22 CST 2008.