Click here to Skip to main content
15,913,090 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Guess what, that site is just wrong. Pin
Marc Clifton17-Nov-17 7:59
mvaMarc Clifton17-Nov-17 7:59 
GeneralRe: Guess what, that site is just wrong. Pin
Jeremy Falcon17-Nov-17 8:25
professionalJeremy Falcon17-Nov-17 8:25 
GeneralRe: Guess what, that site is just wrong. Pin
jsc4218-Nov-17 0:14
professionaljsc4218-Nov-17 0:14 
GeneralRe: Guess what, that site is just wrong. Pin
Jeremy Falcon18-Nov-17 5:25
professionalJeremy Falcon18-Nov-17 5:25 
GeneralRe: Guess what, that site is just wrong. Pin
Jeremy Falcon18-Nov-17 5:27
professionalJeremy Falcon18-Nov-17 5:27 
GeneralRe: Javascript brace style - THAT discussion probably again Pin
PIEBALDconsult17-Nov-17 9:27
mvePIEBALDconsult17-Nov-17 9:27 
GeneralRe: Javascript brace style - THAT discussion probably again Pin
EbenRoux19-Nov-17 20:32
EbenRoux19-Nov-17 20:32 
GeneralRe: Javascript brace style - THAT discussion probably again Pin
John Bevan19-Nov-17 23:40
John Bevan19-Nov-17 23:40 
Generally follow the standards / style guide at your place of work.
However, with JavaScript there can be gotchas; due to semicolons being optional, as per this example:

javascript - Why does a results vary based on curly brace placement? - Stack Overflow[^]

So you have to be cautious that in such cases you use the code that works over the dictated style; and put a comment so no one decides to clean up your formatting not realising that they're introducing a bug.
If you're defining a style, I'd say it's best to pick one which avoids this issue, so going with some variant of K&R makes sense for this language, to avoid such pitfalls & any cognitive load related to spotting them.
For most other languages (i.e. where placement is solely formatting), I'd typically recommend Allman style for clarity (personal preference); though I may suggest K&R for any projects where the same developers are likely to work with JavaScript; again so they don't have to think about it (i.e. when switching languages).

Regarding my personal preference; historically I was a K&R advocate, but later realised that the Allman style allows lining up the open and close brackets, which is more obvious than lining up the code responsible for the bracket. Once you develop the habit of thinking "the line before the open brace is the one defining this block" rather than "the first line of the block defines the block & ends with the opening brace" it pays off. You do use up more screen real estate; but often (at least for developers with large monitors), that's good, since it removes clutter.
GeneralRe: Javascript brace style - THAT discussion probably again Pin
who_me20-Nov-17 3:15
who_me20-Nov-17 3:15 
GeneralRe: Javascript brace style - THAT discussion probably again Pin
Dimitrios Kalemis20-Nov-17 10:25
Dimitrios Kalemis20-Nov-17 10:25 
GeneralRe: Javascript brace style - THAT discussion probably again Pin
obermd20-Nov-17 14:54
obermd20-Nov-17 14:54 
GeneralThought of the Day Pin
OriginalGriff17-Nov-17 4:52
mveOriginalGriff17-Nov-17 4:52 
GeneralRe: Thought of the Day Pin
lopatir17-Nov-17 5:03
lopatir17-Nov-17 5:03 
GeneralRe: Thought of the Day Pin
megaadam17-Nov-17 5:08
professionalmegaadam17-Nov-17 5:08 
GeneralRe: Thought of the Day Pin
W Balboos, GHB17-Nov-17 5:11
W Balboos, GHB17-Nov-17 5:11 
GeneralRe: Thought of the Day Pin
Eddy Vluggen17-Nov-17 5:16
professionalEddy Vluggen17-Nov-17 5:16 
GeneralRe: Thought of the Day Pin
jeron117-Nov-17 5:29
jeron117-Nov-17 5:29 
GeneralRe: Thought of the Day Pin
Ravi Bhavnani17-Nov-17 10:24
professionalRavi Bhavnani17-Nov-17 10:24 
GeneralRe: Thought of the Day Pin
jeron117-Nov-17 12:07
jeron117-Nov-17 12:07 
GeneralRe: Thought of the Day Pin
Ravi Bhavnani18-Nov-17 8:30
professionalRavi Bhavnani18-Nov-17 8:30 
GeneralRe: Thought of the Day Pin
TNCaver17-Nov-17 6:44
TNCaver17-Nov-17 6:44 
PraiseRe: Thought of the Day Pin
MacSpudster17-Nov-17 6:47
professionalMacSpudster17-Nov-17 6:47 
GeneralRe: Thought of the Day Pin
PIEBALDconsult17-Nov-17 6:48
mvePIEBALDconsult17-Nov-17 6:48 
GeneralRe: Thought of the Day Pin
DRHuff17-Nov-17 7:13
DRHuff17-Nov-17 7:13 
GeneralSystem crash screens Pin
Jochen Arndt17-Nov-17 3:12
professionalJochen Arndt17-Nov-17 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.