功能名称后的空格有误吗? [英] Space after function name is wrong?

查看:108
本文介绍了功能名称后的空格有误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是JSLint,但是在函数名后加了一个空格会出错。为什么那么糟糕?

I was using JSLint and I got an error for putting a space after the function name. Why is that bad?

function coolness () {
    var hi = "this";
}

错误:第1行的问题19:酷与酷之间的意外空间'('。

ERROR: Problem at line 1 character 19: Unexpected space between 'coolness' and '('.

推荐答案

JSLint不是Javascript语法检查程序,因为它是一个Javascript样式检查程序。样式指南它用途是道格拉斯克罗克福德写的。

JSLint is not a Javascript syntax checker as much as it is a Javascript style checker. The style guidelines it uses are those written by Douglas Crockford.

有些人不同意他的风格决定,有些人不同意。他们不是法律,你不需要遵守它们。存在替代JS链接,例如 JSHint

Some people do not agree with his style decisions, some people do. They are not law and you are not required to follow them. Alternative JS linters such as JSHint exist.

您遇到的特殊规则是此处


函数名称和参数列表的(左括号)之间不应有空格。

There should be no space between the name of a function and the (left parenthesis) of its parameter list.

Javascript不是空格敏感的。如果是m,你可以添加这个空格让你感觉更好。 (但这不是标准。)

Javascript is not whitespace-sensitive. You can add this space if it makes you feel better. (It is not standard, however.)

这篇关于功能名称后的空格有误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆