Naming
About naming conventions and capitalization.
Constant names
“JavaScript constants are also case-sensitive. However, these constants should be written in uppercase because they are nonchanging variables. If the variable declaration name contains more than one word, you should use UPPER_SNAKE_CASE.”
—syncfusion.com, 2024-02-26
const EXAMPLE_CONSTANT_NAME = "Sweet";
Function names
“For function names, use camel case, starting with a lowercase character.”
—mozilla.org, 2024-02-24
function exampleFunctionName() {
...
}
Other
Things I have yet to categorize, but are important enough to list here.
English
Write code and comments in English instead of your first language. If you namely stop working on the project and people who inherited the project need to find a developer to change it, they will have many more to choose from as the vast majority of developers speak English. Not that many speak Slovene for example.
—SM, 2024-08-17
Single-line comments over multi-line comments
While writing and testing Google Apps Script code I sometimes want to comment out an entire block of it. If I used multi-line comments all over the code, I will not able to do that as the multi-line comment will come to a close at the very first “*/” it encounters.
I know many code editors give advance commenting and uncommenting options, but if you are writing Google Apps Script code inside Google’s native user interface, it is a lot easier to comment out bigger blocks of code by using single-line comments for almost everything and multi-line comments only for testing and development purposes.
/**
* This is how I used to write multi-line comments
* using multi-line comment syntax
*/
//
// This is how I write multi-line comments now
// using single-line comment syntax
//
—SM, 2024-08-17