In php we can define variables mainly in three ways:
- private
- protected
- public
In javascript we can define variables like this:
function myfunc(){
var x = 'private'; // private variable
this.x = 'public'; // public variable
}
Now, I want to know how can I maintain protected variable in javascript?
Is this an answer?
function myfunc(){
var x = { //private variable
protectedVariable = 'protected'; //protected variable?
}
}