The purpose of using closures is to keep the variable private (not directly accessible from the global scope).
Here is how to use a closure:
myApplication.prototype.myFirstMethod = (function () {
var data = '';
return function () {
if (arguments.length) {
data = arguments[0];
} else {
return data;
}
}
})();
If you dont need the data to be private, you can simply do this:
myApplication.prototype.myFirstMethod = function(){
if (arguments.length) {
this.local['firstData'] = arguments[0];
} else {
return this.local['firstData'];
}
};