Context Binding
introduction to context binding, animation of a ball using the setInterval method
In ES5, function scope often requires us to bind the context to a function. Context binding is usually performed in one of the following two ways:
- by defining a
self = this
variable, - by using the
bind
function.
In our first example, we will attempt to animate a ball using the setInterval
method.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.