Size: 995
Comment:
|
Size: 957
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 14: | Line 14: |
* camelCase variables and function names * CapitalCamelCase for classes * [[http://en.wikipedia.org/wiki/Indent_style#Compact_control_readability_style|Compact Control]] indention |
* camelCase variables and function names, CapitalCamelCase for classes, CAPS for namespaces, CAPS for constants and namespaces |
Line 19: | Line 17: |
* `===` for comparisons | * Triple equals (`===`) for comparisons |
Line 38: | Line 36: |
} |
ROS JavaScript Style Guide
Contents
This page defines a style guide to be followed in writing JavaScript code for ROS. This guide applies to all ROS code, both core and non-core.
For Python, see the Python Style Guide and for C++, see the C++ Style Guide
Coding Style
A quick summary is:
- 2 space indention
camelCase variables and function names, CapitalCamelCase for classes, CAPS for namespaces, CAPS for constants and namespaces
- Semicolons are good
JSDoc for documentation
Triple equals (===) for comparisons
An example can be worth a thousand words:
/** * Performs an example task. * * @param foo - task selector */ function exampleTask(foo) { var myVar = 'My message'; if (foo === 'Do this') { anotherExampleTask(myVar); } else { someOtherTask(myVar); } }