Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by foreigner on Friday April 14, 2017 @03:29PM
(#14116578)
One of my coworkers made the good suggestion that "that" is only one character away from "this", so we use "self" instead for the same purpose.
[ Parent
| on HN ]
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by yathern on Friday April 14, 2017 @04:25PM
(#14117017)
Not to be overly pedantic, but I'm I missing something here? "that" -> "this" is a two character change, no?
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by foreigner on Friday April 14, 2017 @05:37PM
(#14117648)
Ha ha of course you're right! Math is hard.
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by kevin_thibedeau on Friday April 14, 2017 @08:56PM
(#14118697)
Barbie? That you?
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by Filligree on Friday April 14, 2017 @03:49PM
(#14116724)
I've always used 'me'. Not for any particular reason, it's just the first name that occurred to me.
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by recursive on Sunday April 16, 2017 @01:14PM
(#14126480)
FYI this is the keyword that Visual Basic uses as well.
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by j79 on Friday April 14, 2017 @06:47PM
(#14118013)
It could get messy if you're doing stuff with Canvas, but I've used "ctx" in the past to denote the context change.
Re:Replacing ‘that = this’ assignments in JavaScript with Ar...
by bjterry on Friday April 14, 2017 @09:31PM
(#14118830)
'self' is also the global variable when you are in a WebWorker context, so it's sort of like overwriting 'window'. When you are in a window context 'self' is also identical with 'window' but people don't usually use it there.