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?
Parenthesis placing after function
113 views Asked by pertrai1 At
2
There are 2 answers
1
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
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