Consider the following Java script code:
var myObj = function ( ) {
var x = 0;
return {
addup: function (y) {
x += y;
},
getX: function ( ) {
return x;
}
}
}();
This function returns an object with two methods (if I am not wrong).
now, two questions:
- how can I call the two methods returned from the function?
- can those methods still have access to the variable x ?
thanks,