I have 2 different ways using my Javascript objects inside an anonymous scope.
(function(){
function MyObject() {
this.MyMethod = function() {
//code here
}
}
first = new MyObject();
first.MyMethod();
})();
And
(function(){
function MyObject(){};
MyObject.prototype.MyMethod = function() {
//code here
}
first = new MyObject();
first.MyMethod();
})();
I am aware that the prototype version is better but am not sure if using an anonymous scope makes a difference to the benefits/drawbacks.