function ReplacePlaceholders() { return 'success'; } exports.sendMailMsg = function (templateName,receiverEmail,dataPlaceholders) { ReplacePlaceholders(); }
解决方法
这实际上是由JSHint生成的错误,但代码将正确运行. The option in JSHint,newcap,导致此错误实际上是折旧,并禁用它是建议的.
关于为什么这个选项甚至在JSHint中的相关信息:
This option requires you to capitalize names of constructor functions. Capitalizing functions that are intended to be used with
new
operator is just a convention that helps programmers to visually distinguish constructor functions from other types of functions to help spot mistakes when using this.Not doing so won’t break your code in any browsers or environments but it will be a bit harder to figure out—by reading the code—if the function was supposed to be used with or without
new
. And this is important because when the function that was intended to be used with new is used without it,this
will point to the global object instead of a new object.