JavaScript Space After Function

I do the same.

function () { ... }
function name() { ... }

It makes more sense to me this way. It is more readable with the space after the function keyword (I do the same with if, while, etc) and it makes sense not to put it after the function name since you usually invoke it without a space.


It is matter of personal preference. No doubt proper spacing does aid to readability which is always a good idea.

The important thing though when it comes to JavaScript coding style, is to always put starting curly brace on the same (due to automatic semi-colon insertion) line unlike:

function myFunc() 
{
    return
    {
        name: 'Jane'
    };
}

var f = myFunc();
console.log(f); // undefined

Read More:

  • Code Conventions for the JavaScript Programming Language