Double Nested “this”
I encountered a problem today that i’m not sure how to deal with efficiently. As you can see in the code below there are three buttons, when one of them is clicked they all move to a designated spot, and then the button that was clicked changes color.
This was what I was hoping to achieve initially, however the background-color changes instantly without giving the buttons a chance to “arrive at their destinations”. I tried to combat this by using a setTimeout(), but the nested function does not recognize the
If someone could give me a workaround that would be great! But in the meantime I’m curious about double nested
this’s. How would one use it within one or more functions? Is it possible?
setTimeout function callback,
this references the global
You need to capture the value of
this outside of that scope: