Skip to content

Instantly share code, notes, and snippets.

@alexesca
Created June 11, 2020 03:21
Show Gist options
  • Save alexesca/aebdbf90933021c2cf717a97cbdbc9a8 to your computer and use it in GitHub Desktop.
Save alexesca/aebdbf90933021c2cf717a97cbdbc9a8 to your computer and use it in GitHub Desktop.
export class MyClass {
static add(num1, num2) {
return num1 + num2;
}
subtract(num1, num2) {
return num1 - num2;
}
}
// MyClass.add(1,2) returns 3
// MyClass.subtract(1,2) gives an error because you need to call new MyClass() before calling the subtract method.
// new MyClass().subtract(1,2) should return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment