lick() is a private method of Cat. Unfortunately, Cat's this.paw is not accessible in lick(). Is there a simple way to create a private method that has access to the member variables of its containing class?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p id="catStatus">???</p>
<script>
function Cat() {
this.paw;
var lick = function() {
alert(this.paw);
if(this.paw == "sticky") {
alert("meow");
document.getElementById("catStatus").innerHTML = "*Slurp*";
}
};
this.beCat = function() {
this.paw = "sticky";
lick();
}
}
var kitty = new Cat();
kitty.beCat();
</script>
</body>
</html>