A quick google and a look at Javascript The Definitive Guide:

"self" is also a property of the global (window) object, one which points back
at the window object such that (window.self === window) should be true (it
isn't in Internet Explorer, but it is in Gecko-based browsers, Netscape 4.78
and Opera 7.53). I'm unsure why people use "self". It requires JavaScript to
step through the object in the DOM you actually want to retrieve a property
which points back at the object you wanted in the first place. I guess it's
useful for self-documenting code (pun not intended). I don't know, I never use
it, when I want the default window object, I use "window".

"this" always refers to the current object. Outside of any function, "this"
would refer to the global (window) object such that (this === window) returns
true. Within functions, "this" can refer to a number of things, but it is
always the "current object". Example:

So, self is property which allows an object (Window) to reference
itself, this refers to the object which sits on the top of the current
scope resolution stack.

btw, self is a part of Client Side Javascript, not the core language.

I maybe reading it out of context, but I don't think knowing this
makes or breaks one's status as a professional Javascript developer.

- jake


On 3/13/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> the infamous ppk wrote in his blog:
>
> "I've learnt one other trick for distinguishing newbies and pros: ask
> them the difference between |this| and |self|. Usually people who just
> claim to be excellent scripters don't know the answer, while real pros do."
>
> So obviously I am not an excellent scripter, because I don't have any
> idea on the difference between those two. And I prefer discussing iton
> this instead of crawling through the ECMA spec.
>
> Anyone?
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to