Is there any considerations to determine which is better practice for creating an object with private members?
var object = new function () {
var private = "private variable";
return {
method : function () {
..dosomething with private;
}
}
}
VS
var object = function () {
...
}();
Basically what is the difference between using NEW here, and just invoking the function immediately after we define it?
new function(){…}
! Admittedly, in this particular case where youreturn
from the function it's not that bad. – Piwowar