Skip to content

Instantly share code, notes, and snippets.

@arcticmouse
Created January 28, 2020 05:02
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 arcticmouse/7d03c70201699b4265f7782809a6342f to your computer and use it in GitHub Desktop.
Save arcticmouse/7d03c70201699b4265f7782809a6342f to your computer and use it in GitHub Desktop.
techtonica create counter class
function createCounter(startingValue){
var counter = startingValue
var newObject = {
getValue: function() { return counter },
increment: function() { return counter++ }
}
return newObject
}
let c = createCounter(1)
console.log("c.counter =>", c.counter)
c.increment()
console.log("c.getValue() =>", c.getValue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment