Y
Hacker News
new
|
ask
|
show
|
jobs
by
karol
3362 days ago
By using `self` you shadow a global variable which is a reference to the current context (window object) in which the code is executed.
2 comments
lexicality
3362 days ago
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.
link
amorgaut
3360 days ago
It matters when you are running in workers in which case the window object does not exists
link
imdsm
3362 days ago
I always found context, i.e. let context = this, to be far more descriptive.
link