<script type="text/javascript">
function Container(param) {
function dec() {
if (secret > 0) {
secret -= 1;
return true;
} else {
return false;
}
}
this.member = param;
var secret = 3;
var that = this;
this.service = function () {
return dec() ? that.member : null;
};
}
myContainer = new Container("terry...");
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.member);
</script>
function Container(param) {
function dec() {
if (secret > 0) {
secret -= 1;
return true;
} else {
return false;
}
}
this.member = param;
var secret = 3;
var that = this;
this.service = function () {
return dec() ? that.member : null;
};
}
myContainer = new Container("terry...");
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.member);
</script>