4 ms·
By using `self` you shadow a global variable which is a reference to the current context (window object) in which the code is executed.
by karol 10y 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.
- imdsm 10y agoI always found context, i.e. let context = this, to be far more descriptive.
- lexicality 10y agoWhich 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.
- amorgaut 10y agoIt matters when you are running in workers in which case the window object does not exists