I came across a piece of logic from a colleague and want to have clarity on the consequences before i submit a change. Basically, I have a class:
var MyClass = function(){};
MyClass.prototype = {...}
In another file, I am defining a module that requires that class and goes a little something like this:
return {
propA: new MyClass().propA,
propB: new MyClass().propB
};
The alternative way would be declaring a new MyClass object and use it like:
var myObject = new MyClass();
return {
propA: myObject.propA,
propB: myObject.propB
};
What would be the advantages and pitfalls of using each one of those?