Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  11] [ 3]  / answers: 1 / hits: 31871  / 12 Years ago, mon, march 19, 2012, 12:00:00

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;
}


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


More From » javascript

 Answers
2

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.



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.



The particular rule you are running into is here:




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




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


[#86757] Saturday, March 17, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;