playing around with some es6 and ran into an issue i'm not sure how to solve. consider the following
class Foo {
constructor ( ) {
window.addEventListener('scroll', this.watch);
}
watch ( ) {
console.log(this);
}
}
Inside of watch
, this
is the window
object, as expected. But how do i refer to Foo
? Currently I get around this with bind this.watch.bind(this)
but i'd love to know if there is a more "proper" ES6 way to get this going.