Created
October 22, 2018 09:41
-
-
Save nelsonfncosta/aa68eacf7115b22410124285262b6548 to your computer and use it in GitHub Desktop.
JS private variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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