简体   繁体   中英

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. 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. Maybe the two are related?

Linters are quite finicky about which of the many styles to make IIFEs work to pick.

In your case you were using two approaches at once, drop the + and JShint should be happy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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