In the code examples below, I understand how alternative 1 and 2 work, but Im trying to understand the third alternative. What kind of object is this and why does it start with a bracket before the function like this: (function
and Why does it end with a double bracket like this: ()
. Just curious and would like to know what is what and the difference?
Alternative 1: (Object Literals)
var something = {
rows: 12;
cols: 6;
};
Alternative 2: (Function Objects)
var something = function(x,y) {
return x + y;
}
Alternative 3: ??
var something = (function() {
var settings = {
rows : 10,
cols : 3,
number : 2
};
})();