Skip to content

Instantly share code, notes, and snippets.

@JustinDFuller
Created January 17, 2019 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinDFuller/922e73aa725be331abdda7ff1ac6982b to your computer and use it in GitHub Desktop.
Save JustinDFuller/922e73aa725be331abdda7ff1ac6982b to your computer and use it in GitHub Desktop.
An example of an extensible interface
// not extensible
function getUser() {
return {
name: 'Justin',
email: 'justinfuller@email.com'
}
}
// Extensible
class User {
constructor(options = {}) {
this.userData = options
}
get() {
return this.userData
}
set(key, value) {
this.userData[key] = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment