Through the constructor creates a counter object:
The function Counter () {
Let count=0;//not this
Enclosing the up=function () {
Return + + count;
};
Enclosing the down=function () {
The return - count;
};
}
Let the counter=new counter ();
Counter. The up ()//1, why can also get the count value here?
My understanding is that counter object has up and down two methods, but should not count this property, such as:
Counter={
The up () {
Return + + count;
},
Down () {
The return - count;
}
}
How can get to the count value?
CodePudding user response:
Let count=0; Defines a local variable is not let people have what relation with properties on it
CodePudding user response: