M
Michael Haufe (\TNO\)
From looking at the code below:
--------------------------------------------------
var Singleton1 = (function(){
//...
return {
foo : function(){
//...
},
bar : function(){
//...
}
};
})();
var Singleton2 = new function(){
//...
this.foo = function(){
//...
};
this.bar = function(){
//...
};
};
-----------------------------------------------
Is there a good reason why jslint should complain about Singleton2,
but not Singleton1?
jslint message:
-----------------------------------------------
Problem at line 13 character 18: Weird construction. Delete 'new'.
var Singleton2 = new function(){
Problem at line 21 character 2: Missing '()' invoking a constructor.
};
-----------------------------------------------
--------------------------------------------------
var Singleton1 = (function(){
//...
return {
foo : function(){
//...
},
bar : function(){
//...
}
};
})();
var Singleton2 = new function(){
//...
this.foo = function(){
//...
};
this.bar = function(){
//...
};
};
-----------------------------------------------
Is there a good reason why jslint should complain about Singleton2,
but not Singleton1?
jslint message:
-----------------------------------------------
Problem at line 13 character 18: Weird construction. Delete 'new'.
var Singleton2 = new function(){
Problem at line 21 character 2: Missing '()' invoking a constructor.
};
-----------------------------------------------