Skip to content
Tom Brasington edited this page Jan 3, 2014 · 14 revisions

Whitespace

  • Four spaces per tab.
  • Indent/align with spaces.
  • No tab characters.
  • End files with one blank line.
  • Round braces are snug:
    // Like so:

    if (foobar)
    {
    }

    foo(bar, baz);

    // Not like:

    if ( foobar )
    {
    }

    foo( bar, baz );

Curly Braces

  • Go on their own line:
    function foo()
    {
        return "bar";
    }

    if (foobar)
    {
    }

    while (foobar)
    {
    {

Semicolons

  • After any expression, return statement, or var statement:
    var a = b;
 
    if (foo)
    {
    }

    while (foo)
    {
    }

    function baz()
    {
        return 42;
    }

    var foo = function ()
    {
        return 42;
    };

Commas

  • Go at the end of the line:
    var foo = {
        bar : 'bar',
        baz : 'baz'
    };

Other

Please have a look at some of the Higgs source code to get a general impression of the style being used.

Clone this wiki locally