Possible Duplicate:
Javascript: Do I need to put this.var for every variable in an object?
I wanted to create a "class" in JavaScript which other "classes" should inherit from.
Thus, I added "public methods" using the prototype object.
Inside these methods, I want to access private properties of my class.
It seems like I cannot access them. How do I do this? This is my code:
<!doctype html>
<html>
<head>
<title>OOP test</title>
<script>
var ParentClass = function(){
var data = [];
}
ParentClass.prototype.addData = function(somedata){
data.push(somedata); // ReferenceError: Can't find variable: data
}
var p = new ParentClass();
p.addData("foo");
</script>
</head>
<body>
</body>
</html>