{Tips for Javascript} K&R vs Allman style of writing code.
In JavaScript the result of a method can depend upon the style braces are placed. This is the K&R style, where braces are placed right after the method signature and after a return statement: var foo = function() { return { key: 'value' }; } foo() // returns an object here Now, if I format this code to the Allman style, where braces are always placed on a new line, the result is different: var foo = function() { return { key: 'value' }; } foo() // returns undefined here How come? In JavaScript the language places automatically semicolons at the end of each line if you won't do it yourself. So what really happened in the last code fragment was this: var foo = function() { return; // here's actually a semicolon, automatically set by JavaScript! { key: 'value' }; } So if you'd call foo(), the first statement in the method would be a return statement, which would return undefined and would not execute other following statements. Source: Stackoverflow