Skip to content

Instantly share code, notes, and snippets.

@casprwang
Last active February 14, 2017 06:25
Show Gist options
  • Save casprwang/82e342330b663df981dff9c33ecc6e6f to your computer and use it in GitHub Desktop.
Save casprwang/82e342330b663df981dff9c33ecc6e6f to your computer and use it in GitHub Desktop.
function higher (d) ({
add3: () => (d + 3)
})
const higher = (d) => ({
add3: () => d + 3
})
class higher {
constructor (d) {
this.d = d
}
add3 () {
return this.d + 3
}
}
const c = new higher(3)
// console.log(typeof(higher))
console.log(c.add3())
@casprwang
Copy link
Author

Two way to declare a class(function)

  1. Declare a function
  2. Declare a class without a constructor
  3. Declare a class with a constructor

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