News for hackers. Stuff that matters.
Re:What does ‘that = this’ in JavaScript mean? by karol on Saturday April 08, 2017 @05:10PM (#14069058)
By using `self` you shadow a global variable which is a reference to the current context (window object) in which the code is executed.
Re:What does ‘that = this’ in JavaScript mean? by lexicality on Saturday April 08, 2017 @06:20PM (#14069380)
Which should be accessed by window.self anyway so it doesn't really matter? There are so many poorly named global variables (top etc) that worrying about shadowing them seems meaningless.
Re:What does ‘that = this’ in JavaScript mean? by amorgaut on Monday April 10, 2017 @02:19AM (#14076451)
It matters when you are running in workers in which case the window object does not exists
Re:What does ‘that = this’ in JavaScript mean? by imdsm on Saturday April 08, 2017 @05:24PM (#14069114)
I always found context, i.e. let context = this, to be far more descriptive.