多行字符串字面量

var myString = 'A rather long string of English text, an error message \
actually that just keeps going and going -- an error \
message to make the Energizer bunny blush (right through \
those Schwarzenegger shades)! Where was I? Oh yes, \
you\'ve got an error and all the extraneous whitespace is \
just gravy. Have a nice day.';

var myString = 'A rather long string of English text, an error message ' +
'actually that just keeps going and going -- an error ' +
'message to make the Energizer bunny blush (right through ' +
'those Schwarzenegger shades)! Where was I? Oh yes, ' +
'you\'ve got an error and all the extraneous whitespace is ' +
'just gravy. Have a nice day.';

/**
* Takes four arguments, two of which are nullable, and two of which are
* optional.
* @param {!Object} nonNull Mandatory (must not be undefined), must not be null.
* @param {Object} mayBeNull Mandatory (must not be undefined), may be null.
* @param {!Object=} opt_nonNull Optional (may be undefined), but if present,
* must not be null!
* @param {Object=} opt_mayBeNull Optional (may be undefined), may be null.
*/
function strangeButTrue(nonNull, mayBeNull, opt_nonNull, opt_mayBeNull) {
// ...
};

编译器已经有限的支持模板类型。它只能推断的类型,这在一个匿名函数字面量从类型的这个论点,是否这个论点是缺失的。The compiler has limited support for template types. It can only
infer the type of this inside an anonymous function
literal from the type of the this argument and whether the
this argument is missing.

/**
* A JSDoc comment should begin with a slash and 2 asterisks.
* Inline tags should be enclosed in braces like {@code this}.
* @desc Block tags should always start on their own line.
*/

JSDoc 缩进

如果你不得不换行块标签，那就应该缩进四个空格以保持注释内容的结构清晰。

/**
* Illustrates line wrapping for long param/return descriptions.
* @param {string} foo This is a param with a description too long to fit in
* one line.
* @return {number} This returns something that has a description too long to
* fit in one line.
*/
project.MyClass.prototype.method = function(foo) {
return 5;
};

你不应该缩进 @fileoverview 命令。

尽管缩进至与上排注释同列并不怎么好，但也是可以接受的。

/**
* This is NOT the preferred indentation method.
* @param {string} foo This is a param with a description too long to fit in
* one line.
* @return {number} This returns something that has a description too long to
* fit in one line.
*/
project.MyClass.prototype.method = function(foo) {
return 5;
};

/**
* Moves to the next position in the selection.
* Throws {@code goog.iter.StopIteration} when it
* passes the end of the range.
* @return {Node} The node at the next position.
*/
goog.dom.RangeIterator.prototype.next = function() {
// ...
};

Indicates that a term in a JSDoc description is code so it may
be correctly formatted in generated documentation.

Marks a variable as read-only and suitable for inlining.
Generates warnings if it is rewritten.

Constants should also be ALL_CAPS, but the annotation
should help eliminate reliance on the naming convention.
Although @final is listed at jsdoc.org and is supported as
equivalent to @const in the compiler, it is discouraged.
@const is consistent with JS1.5's const keyword. Note that
changes to properties of const objects are not currently
prohibited by the compiler (inconsistent with C++ const
semantics). The type declaration can be omitted if it can be
clearly inferred. If present, it must be on its own line. An
additional comment about the variable is optional.

Indicates a constant that can be overridden by the compiler at
compile-time. In the example, the compiler flag
--define='goog.userAgent.ASSUME_IE=true'
could be specified in the BUILD file to indicate that the
constant goog.userAgent.ASSUME_IE should be replaced
with true.

Indicates that the keys of an object literal should
be treated as properties of some other object. This annotation
should only appear on object literals.

Notice that the name in braces is not a type name like
in other annotations. It's an object name. It names
the object on which the properties are "lent".
For example, @type {Foo} means "an instance of Foo",
but @lends {Foo} means "the constructor Foo".

/**
* @preserve Copyright 2009 SomeThirdParty.
* Here is the full license text and copyright
* notice for this file. Note that the notice can span several
* lines and is only terminated by the closing star and slash:
*/

Anything marked by @license or @preserve will be retained by
the compiler and output at the top of the compiled code for
that file. This annotation allows important notices (such as
legal licenses or copyright text) to survive compilation
unchanged. Line breaks are preserved.

This annotation can be used as part of function and
constructor declarations to indicate that calls to the
declared function have no side-effects. This annotation
allows the compiler to remove calls to these functions if the
return value is not used.

Indicates that a method or property of a subclass
intentionally hides a method or property of the superclass. If
no other documentation is included, the method or property
also inherits documentation from its superclass.

Used in conjunction with a trailing underscore on the method
or property name to indicate that the member is
private.
Trailing underscores may eventually be deprecated as tools are
updated to enforce @private.

Used with method and function calls to document the return
type. When writing descriptions for boolean parameters,
prefer "Whether the component is visible" to "True if the
component is visible, false otherwise". If there is no return
value, do not use an @return tag.

Type names must be enclosed in curly braces. If the type
is omitted, the compiler will not type-check the return value.