Skip to content

Instantly share code, notes, and snippets.

@pdbradley
Created May 23, 2019 21:37
Show Gist options
  • Save pdbradley/ded11849a3f3b53f408a1e63c4b0e733 to your computer and use it in GitHub Desktop.
Save pdbradley/ded11849a3f3b53f408a1e63c4b0e733 to your computer and use it in GitHub Desktop.
help us dave
class dontGetIt {
constructor() {
this.foo = 'hello';
}
hello() {
this.foo;
}
}
dgi = new dontGetIt;
dgi.hello();
// why does line 12 return undefined and not 'hello'
@pdbradley
Copy link
Author

how can I set values in the constructor that I can access in any of the included functions in the class? similar to instance variables in a ruby class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment