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

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.
It matters when you are running in workers in which case the window object does not exists
I always found context, i.e. let context = this, to be far more descriptive.