javascript - Error : missing new prefix when invoking a constructor -


i trying create function in node.js. following relevant code, gives me error when call function.

function replaceplaceholders() {             return 'success';           }            exports.sendmailmsg = function (templatename, receiveremail, dataplaceholders) {          replaceplaceholders(); } 

in node.js, function names camel cased, , should start lowercase character. starting function uppercase character tells jshint consider function constructor rather method.

this error being generated jshint, code run correctly. the option in jshint, newcap, causes error depreciated, , disabling recommended.

the relevant info why option in jshint:

this option requires capitalize names of constructor functions. capitalizing functions intended used new operator convention helps programmers visually distinguish constructor functions other types of functions spot mistakes when using this.

not doing won't break code in browsers or environments bit harder figure out—by reading code—if function supposed used or without new. , important because when function intended used new used without it, this point global object instead of new object.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -