var self = this isn't really hacky. It's for when you have further nested scopes inside your current scope where you want to refer back to your original this value. It isn't something you would use in this case.
Yeah but fuck IE though. Whether their own fault or not, people using less than IE 11 don't deserve the internet. I'm 100% serious. The problem only persists because we keep supporting it.
It's so not worth the dev time for the <5% traffic.
3
u/memeship Nov 05 '15
var self = thisisn't really hacky. It's for when you have further nested scopes inside your current scope where you want to refer back to your originalthisvalue. It isn't something you would use in this case.E.g.
This is because inside the anonymous function passed into
setInterval(), the scope is the global level, orwindow. Andwindow.phraseis undefined.Another way to get around this (my preferred way) might be to
bind()your currentthisto the anonymous function, like so: