I'm trying to learn JS and came across some examples formatted like below. The testModule function is fully enclosed in parentheses, but then there is an extra set of parentheses directly following it (right below the closing semi-colon). What is this set of parentheses there for? Thanks for the insights!
var testModule = (function () {
var counter = 0;
return {
incrementCounter: function () {
return counter++;
},
resetCounter: function () {
console.log( "counter value prior to reset: " + counter );
counter = 0;
}
};
})();