I have the following function
var myInstance =  (function() {
  var privateVar = 'Test';
  function privateMethod () {
    // ...
  }
  return { // public interface
    publicMethod1: function () {
      // all private members are accesible here
        alert(privateVar);
    },
    publicMethod2: function () {
    }
  };
})();
what's the difference if I add a new to the function. From firebug, it seems two objects are the same. And as I understand, both should enforce the singleton pattern.
var myInstance =  new (function() {
  var privateVar = 'Test';
  function privateMethod () {
    // ...
  }
  return { // public interface
    publicMethod1: function () {
      // all private members are accesible here
        alert(privateVar);
    },
    publicMethod2: function () {
    }
  };
})();
 
    