Can someone explain this OOP javascript structure?
I realize it is how you create 'objects' in javascript, just need some explanation on the notation and what it means:
var vote = function(){
return {
P1: function() {
alert('P1');
},
P2: function() {
alert('P2');
}
};
}();
vote.P1();
vote.P2();
Why are the public methods in the return call? How is this possible? Separated by commas?
Why does the end of the 'object' have to be (); ?
Naming convention for internal methods and public methods?
Are public properties and methods the same structure? What is the difference?