For functions and methods, including anonymous lambda functions, I keep the opening brace on the next line by itself. For objects and everything I put the opening brace on the line with the declaration.
Will 'favoriteThings' even compile with that final comma?
Oof, 6 months old buuuuttt. Yes, it does compile. Just like js, it's there for convenience when editing. You can't however do that in object initializers e.g.:
varobj=newMyClass{item1,//shorthand if same nameitem2=item2,//<—this comma gives error};
(on mobile, fingers crossed for formatting)
We're a place where coders share, stay up-to-date and grow their careers.
For functions and methods, including anonymous lambda functions, I keep the opening brace on the next line by itself. For objects and everything I put the opening brace on the line with the declaration.
Will 'favoriteThings' even compile with that final comma?
In JavaScript, the final comma is optional. In many other languages, that might not be the case.
Oof, 6 months old buuuuttt. Yes, it does compile. Just like js, it's there for convenience when editing. You can't however do that in object initializers e.g.:
(on mobile, fingers crossed for formatting)