Parenthesis placing after function

119 views Asked by At

Which is the common best practice for where to place parenthesis after a function? I see at times function () and I see function(). With parameters I see function (param) and then I see function(param. Is this just a matter of preference or is there a reason as to why there would be whitespace after the function or there would not be whitespace?

2

There are 2 answers

2
Karthick Manoharan On BEST ANSWER

JavaScript is not white space sensitive.you define your coding style.

Though having white space between the function and parenthesis is no sin. If you follow crockford's javascript standards. He advises not to have space in between.

http://javascript.crockford.com/code.html#function

1
Manish Jangir On

The size of the indent is usually independent of the style. Many early programs used tab characters for indentation, for simplicity and to save on source file size. Unix editors generally view tabs as equivalent to eight characters, while Macintosh and Microsoft Windows environments would set them to four, creating confusion when code was transferred back and forth. Modern programming editors are now often able to set arbitrary indentation sizes, and will insert the appropriate combination of tabs and spaces. For Ruby, many shell programming languages, and some forms of HTML formatting, two spaces per indent level is generally used.

Read full on Code Indent Style in Programming