简体   繁体   English

导致JSHint警告的未知函数语法

[英]Unknown function syntax causing JSHint warning

I have a function declared like so; 我有一个这样声明的函数;

+(function () { ... }());

Not my code, but I've been tasked with maintaining it, so knowing what's going on would be mighty handy. 不是我的代码,但是我的任务是维护它,所以知道发生了什么会很方便。 That's the only thing in the file, nothing else. 那是文件中唯一的东西,仅此而已。 JSHint complains with Expected an assignment or function call and instead saw an expression. JSHint抱怨“ Expected an assignment or function call and instead saw an expression. and points to the )) as being the issue. 并指出))

I've got a very basic understanding of why there's brackets around the function, although that understanding could definitely be improved. 我对为什么在函数周围使用方括号有一个非常基本的了解,尽管可以肯定可以改善这种理解。 I don't know what the + is for. 我不知道+是什么意思。 Nor do I know why JSHint is complaining. 我也不知道JSHint为什么抱怨。 Maybe the two are related? 也许两者是相关的?

Linters are quite finicky about which of the many styles to make IIFEs work to pick. 对于使IIFE可以选择的多种样式中的一种 Linters 非常挑剔

In your case you were using two approaches at once, drop the + and JShint should be happy. 在您的情况下,您一次使用了两种方法,请删除+和JShint应该很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM