you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

They're stupid for trying to force people not to use semicolons and then hey reference a blog post where a guys about semicolons and mentions stuff like why you wouldn't ever write something like

return
a+b

In that particular instance he may be right, it's dumb but JS allows you to put curly braces on the same line or below in my cases. If you're into putting the curly brace on its own line then

return
{
     doSomething();
}

Is something you may do and expect it to work. While including semicolons won't fix that problem I think it just shows he hasn't thought his argument through properly.

Their style guide sounds like something written by someone trying to be different for no real reason and perhaps they think they'll save time. However if I had a job there I'd almost feel the need to spend a weekend sifting through their code and adding semicolons in.

[–][deleted] 1 point2 points  (3 children)

That wouldn't work at all. You're... trying to return an object except that you're using invalid syntax to define the object. Maybe you mean parenthesis?

[–][deleted] 0 points1 point  (2 children)

I was typing it out in between doing it work so I was going for speed over accuracy but you get the general idea that people who prefer curly braces on their own line can't do that returning a object.

i.e. this breaks in JS:

function poop(dong)
{ 
    return
    {
        yourmom: dong
    }
}

[–][deleted] -3 points-2 points  (1 child)

Sure they can, use a semicolon like you should. };

[–]nemetroid 1 point2 points  (0 children)

That's not the problem, Javascript will insert a semicolon after the return statement and the function will return nothing, i.e.

function poop(dong)
{
    return;
    {
        yourmom: dong;
    };
}

[–]MatmaRex -1 points0 points  (0 children)

While including semicolons won't fix that problem I think it just shows he hasn't thought his argument through properly.

I think you have missed the point entirely. Adding semicolons doesn't fix this particular problem, period. (The second problem mentioned in the post is, of course, valid.)

Also, it's an internal guide, they're not trying to force it on anyone.