DEV Community

Cover image for How to comment in Javascript?
Dennis Ng'ang'a Mbugua
Dennis Ng'ang'a Mbugua

Posted on

How to comment in Javascript?

Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.
There are two ways to write comments in javascript:

Using // will tell JavaScript to ignore the remainder of the text on the current line. This is an in-line comment:

// This is an inline comment in javascript

You can make a multi-line comment beginning with /* and ending with */. This is a multi-line comment:

/* This is an multi-line comment */

NOTE:As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others and for your future self.

Tip:try commenting by writing each one of them today.

By Dennis Mbugua Programmer and writer

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay