๐ŸŒฑ Growing Every Day โ€” Early access. New content drops regularly!

content

JS Docs

JS Docs are a way for us to document portions of our code to make it quicker and easier for us and others to understand. It's the information that appears in a tooltip when you hover over a variable or function.

Basic JS Docs example

In addition to this:

  • JS Docs can be automatically turned into TypeScript types
  • JS Docs can automatically generate documentation for your JS Docs documented code.

[JS Docs video]

Basics

JS Docs works by enclosing the information with opening /** and closing */ tags. That information is then displayed in a tooltip when hovering over a function or variable.

In this example, we have a function that adds two numbers. We add a basic description between the /** and */ tags. We can then see a tooltip containing this description when hovering over the function call.

/** Adds two numbers together and returns the results */
function addNumbers(a, b) {
return a + b;
}

Basic JS Docs example

Exercises

Exercise 1:

Additional resources

JS Doc: Documentation

Lesson Complete!

Great job! You've finished this lesson. Ready to continue?