Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
const self = this is not solving the problem that this could be bound ambiguously. It is simply solving the problem where each function would have their own this. E.g.
const self = this
is not solving the problem thatthis
could be bound ambiguously. It is simply solving the problem where eachfunction
would have their ownthis
. E.g.I like using bind to solve this problem tho:
But of course the nicest way would be using arrow functions: