I have already read this post : JSLint, else and Expected exactly one space between '}' and 'else' error and it didn't help me to know the reason of this rule.
EDIT : I see that my question is set to duplicated, but I have mention the first line that I came from this post and I could not find the answer until the other post talk about the return line before a {
when My question ask for the space between )
and {
. SO I don't see a reason for duplicated. Thanks
I always use to write my function / statement, without any space. Like this :
This is wrong for JSLint :
var myFn = function(data){
}
if(true){
}else{
}
This is correct for JSLint :
var myFn = function (data) {
}
if (true) {
} else {
}
This lead me through the error. But for which reason it is better to add a space between the function
and the (
? And between the )
{
?
I see that like a waste of time to add all this space every time. Why this decision?
EDIT On http://www.jslint.com/help.html , we can read "The word function is always followed with one space.
Spaces are used to make things that are not invocations look less like invocations."
So that is kind of answer I was looking for.
I don't know if I am ready for this... :D