Skip to content

Instantly share code, notes, and snippets.

@dtoki
Last active June 21, 2018 18:42
Show Gist options
  • Save dtoki/0895111da239c8f28e7f0e8f5dc96940 to your computer and use it in GitHub Desktop.
Save dtoki/0895111da239c8f28e7f0e8f5dc96940 to your computer and use it in GitHub Desktop.
Local this debug scope undefined in vs code
class Automobile {
constructor(type, year, mph) {
this.type = type;
this.year = year;
this.mph = mph;
Automobile.staticMethod(() => {
console.log(this);
this.nonStaticMethod();
});
}
static staticMethod(callback) {
console.log('in static method');
console.log(this);
callback(true);
}
nonStaticMethod() {
console.log('in non static method');
console.log(this);
const foo = () => {
const bar = this;
console.log(bar);
};
foo();
}
}
const car = new Automobile('suv', 2012, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment