Open In App

How to Create a Single Line Comment in JavaScript ?

Last Updated : 29 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In JavaScript, you can create a single-line comment using the // double forward slash. Everything following // that line will be treated as a comment and will not be executed.

Example: the lines starting with // are single-line comments. They are ignored by the JavaScript interpreter and are purely for the benefit of developers to add explanations or notes in the code.

// This is a single-line comment

let x = 5; // You can also add a comment at the end of a line of code

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads