-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I wrote a Class like your book as below ,
`
var MyClass= (function() {
var _privateField1 ;
function MyClass(fild1) { _privateField1 = fild1;}
MyClass.prototype.GetDoubleField1=function(){return _privateField1*2;}
return MyClass;
}());var obj1 = new MyClass(1);
var obj2 = new MyClass(2);
console.log(obj1.GetDoubleField1());//should be 2 ,actually 4,how to solve it .
console.log(obj2.GetDoubleField1());
I think this is a popular way in C# ,but this makes a problem . How to solve it ,Thank you . Encapsulation is actually not supported in this exaple
Metadata
Metadata
Assignees
Labels
No labels