4.8 Comments
This section addresses implementation comments. JSDoc is addressed separatelyin ??.
4.8.1 Block comment style
Block comments are indented at the same level as the surrounding code. They maybe in / … /
or //
-style. For multi-line / … /
comments, subsequentlines must start with aligned with the on the previous line, to makecomments obvious with no extra context.
/*
* This is
* okay.
*/
// And so
// is this.
/* This is fine, too. */
Comments are not enclosed in boxes drawn with asterisks or other characters.
Do not use JSDoc (/* … /
) for implementation comments.
4.8.2 Parameter Name Comments
“Parameter name” comments should be used whenever the value and method name donot sufficiently convey the meaning, and refactoring the method to be clearer isinfeasible .Their preferred format is before the value with =
:
someFunction(obviousParam, /* shouldRender= */ true, /* name= */ 'hello');
For consistency with surrounding code you may put them after the value without=
:
someFunction(obviousParam, true /* shouldRender */, 'hello' /* name */);