that, self or me — which one to prefer in JavaScript?
Posted
by Török Gábor
on Stack Overflow
See other posts from Stack Overflow
or by Török Gábor
Published on 2010-04-23T13:19:43Z
Indexed on
2010/04/23
13:43 UTC
Read the original article
Hit count: 181
While coding JavaScript sometimes you store the reference of object this
in a local variable for different purposes (to set proper scope, to help code obfuscators, etc.). There are coders who prefer aliasing this
to that
to make it obvious its intention. Other guys use self
since it's pointing to the object itself. I even saw source codes where me
held the reference and it still makes sense. Certainly there are other ones.
Which one should I prefer? Is there a convention on which to use or is it only the matter of taste.
© Stack Overflow or respective owner