Comments
Anonymous contributor
Anonymous contributor3071 total contributions
Anonymous contributor
Published May 6, 2021Updated Oct 14, 2023
Contribute to Docs
Comments are pieces of text within a JavaScript program that is not interpreted or executed. They provide additional information to aid in understanding the code.
Single-line Comments
Single-line comments are created with two consecutive forward slashes //
:
// Prints 5 to the consoleconsole.log(5);
A single-line comment can also be used inline to comment after a line of code:
console.log(5); // Prints 5
Multi-line Comments
Multi-line comments are created by surrounding the lines with /*
at the beginning and */
at the end. Comments are good for a variety of reasons like explaining a code block or indicating some hints, etc.
/*The configuration below must bechanged before deployment.*/let baseUrl = 'localhost/taxwebapp/country';
This syntax can also be used to comment something out in the middle of a line of code:
console.log(/* IGNORED! */ 5); // Still prints 5
Codebyte Example
The code in the following that is not commented out will execute when the program is run:
All contributors
- Anonymous contributorAnonymous contributor3071 total contributions
- design246136080119 total contributions
- codesciousness1 total contribution
- BrandonDusch580 total contributions
- christian.dinh2476 total contributions
- Anonymous contributor
- design2461360801
- codesciousness
- BrandonDusch
- christian.dinh
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.