Private variable vs local variable?


#1



whats the different between private variable and local variable?



#2

private variable is specific to a class and cannot be inherited. Any variable within a block is a local variable and hence it is mentioned explicitly as local.


#3
Code
var Test = function(){
    var test = 0;
    this.addOne = function(){
        test++;
    };
    this.showTest = function(){
        return test;
    };    
};

var newTest = function(){};

newTest.prototype = new Test();



var myTest = new newTest();
myTest.addOne();
myTest.showTest();

Seems like you can inherit them.

@kevinmogi Local variables are tied to the scope of a function and cannot be accessed from outside of it, and private variables are variables that are tied to the scope of an object, in the sense that you cannot access them from outside other than by using functions that are part of the object as well.