Mega Man Mega Man - 1 year ago 139
Javascript Question

JavaScript - this inside of timeout with arrow functions

Why isn't

inside of the
equal to the object that invoked the render function when using arrow functions?

class X {
constructor(config) { =;
this.render_ = config.render;
render() {
var x = new X({
data: [1, 2, 3],
render: (data) => {
setTimeout(() => {
}, 200);

Answer Source

Read the part of the arrow function documentation that says "Arrow functions used as methods"

in summary: arrow functions just simply do not bind this or their own version of this, but rather references the global Window object.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download