Introduction to JavaScript – Comments

As we write JavaScript, we can create comments in our code. Programs do not evaluate comments when you run them. In other words, they exist just for human readers. Good comments are useful for you and other developers because they describe what the code does.

There are two types of code comments in JavaScript:

1) A single line comment will comment out a single line and is denoted with two forward slashes // preceding a line of JavaScript code.

// The first 5 decimals of pi
console.log('Pi is equal to ' + 3.14159);

2) A multi-line comment will comment out multiple lines and is denoted with /* to begin the comment, and */ to end the comment.

/*
console.log('All of this code');
console.log('Is commented out');
console.log('And will not be executed);
*/


Below is some sample code in a compiler for you to practise your commenting for JavaScript. Remember: The more you code the more you know and the better you get. Go ahead and add/remove comments from the exercise below:


JavaScript Comments


JavaScript comments can be used to explain JavaScript code, and to make it more readable.

JavaScript comments can also be used to prevent execution when testing an alternative code.


Related Links:

My little pony learning game in VB.NET

Methods of teaching programming

See the JavaScript Glossary on Code Comments

Online JavaScript Compiler. Code on the go.

W3School – JavaScript Comments

Introduction to JavaScript – Built-in Methods

Learn Code Introspection Python Programming

CSS, HTML, JAVASCRIPT, Online Compiler. Code on the go by replit.it

Python Online Compiler Code on the Go

What is a Blog?

Introduction to JavaScript – Review Types and Operators

Introduction to JavaScript – Variables: Review

Why do most sites use cookies?

Learn RE – Regular Expressions in Python

Introduction to JavaScript – Control Flow: True and False values

Computer programming education goes viral in China

Who is this Android App Development course for?

Introduction to JavaScript – Control Flow: True and False values

The Python Standard Library Ver 3.6.5

Alice Teaches OOP (Glossary of useful terms)

Hello World Android app built with Android Studio

How to make a Go-Back Input button with inline JavaScript

Introduction to JavaScript – Control Flow: if/else Statements

FAQs