Skip to content

Instantly share code, notes, and snippets.

@nelsonfncosta
Created October 22, 2018 09:41
Show Gist options
  • Save nelsonfncosta/aa68eacf7115b22410124285262b6548 to your computer and use it in GitHub Desktop.
Save nelsonfncosta/aa68eacf7115b22410124285262b6548 to your computer and use it in GitHub Desktop.
JS private variable
function Container(param) {
let secret = 3;
let that = this;
this.member = param;
function dec() {
if (secret > 0) {
secret -= 1;
return true;
} else {
return false;
}
}
this.service = function () {
return dec() ? that.member : null;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment