Show Menu

Closure JSDoc Cheat Sheet by

The subset of JSDoc supported by Google Closure Compiler.
javascript     google     documentation     jsdoc     closure

JSDoc Tags for Functions

Function is a constr­uctor (can new)
Function is deprec­ated
@extends {Type}
Function inherits Type
@imple­ments {Type}
Function imple­ments Type (with @const­ruc­tor)
Function has same JSDoc as superc­lass
Function is interface (no new)
Can be removed if return value not used
Function overrides superc­lass
@param {Type} varname Descri­ption
Function takes varname of Type
Function is private (same file or static­/in­stance members)
Function is protected (same file or static­/in­stance of subcla­sses)
@return {Type} Descri­ption
Function returns Type
@this {Type}
In Function, this is Type

JSDoc Tags for Properties

Property is constant
Property can be overridden by compiler
Property is deprec­ated
@enum {Type}
Property is an enum of Type (default number)
Property not optimized by compiler
@lends {objec­tName}
Keys of object are same as property of other object (see: http:/­/co­de.g­oo­­m/p­/js­doc­-to­olk­it/­wik­i/T­agL­ends)
Property is private
Property is protected
@type {Type}
Property is {Type}

JSDoc Type Defini­tions

defined type Window
defined type goog.u­i.Menu
{Objec­t.<­string, number­>}
{'a':1, 'b':2}
1 or True
{{myNum: number, myObject}}
Record with property myNum {number} and myObject {Object}
Array of {Objects} with property length
{number} or null
{Object} but never null
{funct­ion­(st­ring, boolean)}
Function with params and unknown return value
{funct­ion(): number}
Function retur­ning number
{funct­ion­(th­is:­goo­g.u­i.Menu, string)}
Function where this is goog.u­i.Menu
{funct­ion­(ne­w:g­oog.ui.Menu, string)}
Function takes string, creates new goog.u­i.Menu
{funct­ion­(st­ring, ...[nu­mber])}
Function takes string then optional number s
@param {­mber} var_args
Variable number of parameters of type number
@param {number=} opt_ar­gument
Optional parameter of type number
{funct­ion­(?s­tring=, number=)}
Function with optional parame­ters
Variable can take any type
Variable can take any type and don't type check

JSDoc Example

* Creates an instance of Circle.
* @const­ructor
* @this {Circle}
* @param {number} r The desired radius of the circle.
function Circle(r) {
/* @private / this.r­adius = r;
/* @private / this.c­irc­umf­erence = 2 Math.PI r;

* Creates a new Circle from a diameter.
* @param {number} d The desired diameter of the circle.
* @return {Circle} The new Circle object.
*/­omD­iameter = function (d) {
return new Circle(d / 2);

* Calculates the circum­ference of the Circle.
* @depre­cated
* @this {Circle}
* @return {number} The circum­ference of the circle.
*/­oto­typ­e.c­alc­ula­teC­irc­umf­erence = function () {
return 2 Math.PI this.r­adius;

* Returns the pre-co­mputed circum­ference of the Circle.
* @this {Circle}
* @return {number} The circum­ference of the circle.
*/­oto­typ­e.g­etC­irc­umf­erence = function () {
return this.c­irc­umf­erence;

* Find a String repres­ent­ation of the Circle.
* @override
* @this {Circle}
* @return {string} Human-­rea­dable repres­ent­ation of this Circle.
*/­oto­typ­e.t­oString = function () {
return "A Circle object with radius of " + this.r­adius + ".";

Download the Closure JSDoc Cheat Sheet

2 Pages

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!



No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          AngularJS Cheat Sheet
          JavaScript Cheat Sheet