Skip to content

Instantly share code, notes, and snippets.

@hex13
Last active July 7, 2017 12:25
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 hex13/8d55f35389b02f8eb396209a633f4d4a to your computer and use it in GitHub Desktop.
Save hex13/8d55f35389b02f8eb396209a633f4d4a to your computer and use it in GitHub Desktop.
// object literal. Very flexible and with shorthand notation for methods, it's very nice.
const obj = {
addTodo() {
},
removeTodo() {
},
transactions: { // sub object
fetchTodos() {
}
}
}
// ES6 (without drafts)
class ToDo {
// I don't want to do this because it's draft.
// static transactions = {
// fetchTodos() {}
//}
addTodo() {
}
removeTodo() {
}
}
// so old way
ToDo.prototype.transactions = {
fetchTodos() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment