Readability and maintainability are important in software development.
In collaborative projects, code alone often does not make the author's intent clear.
Recently, I have been responsible for defining conventions at work and have thought about how to make code easier for teammates to understand.
While inspecting npm modules, I often found configuration files consisting of more comments than code, and realized how much those comments helped me understand them.
This article explores writing comments in JavaScript and TypeScript, especially for collaboration.
JSDocโ is a way to document JavaScript code, explaining its meaning and usage.
An IDE can extract and display information from these comments, making the code easier to understand.
They can also generate API documentation automatically.
The following image shows the information VS Code displays when hovering over Next.js's Link component.
It comes from JSDoc comments and includes parameters, return values, and even prose explanations.
Use JSDoc to standardize comments in JavaScript and TypeScript so collaborators can understand the purpose and usage of code.
This article covers