On 9/14/06, Juergen Schreck <[EMAIL PROTECTED]> wrote:
>
> Here's another MochiKit [greenhorn] question...
>
> My code is filling up with self references to an object:
>
>
> var myHardWorkingObject = {
>
> 'myprop1' : null,
> 'myprop2': null,
>
> doALotOfStuff: function () {
> var self= myHardWorkingObject; // <-- yuck?!
> self. doALotMoreStuff();
> },
In JavaScript, "self" is called "this" and it's available implicitly.
You will see "var self = this;" sometimes in code. This is done so
that an inner function can reference the "this" from the scope it was
created in.. beacuse "this" is created by call syntax, not bound
methods as in Python.
http://bob.pythonmac.org/archives/2005/07/06/this-sucks-in-javascript/
-bob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---