Learn
HTML list items
Comments
Comments allow us to explain our code, provide context, and make notes about its functionality or purpose. They can also be used to temporarily disable certain parts of our code during testing or debugging.
There are two types of comments in JavaScript:
-
Single-line comments: Single-line comments are denoted by double slashes (
//
) at the beginning of the line. Anything after the double slashes will be ignored by the JavaScript interpreter.Example:
Single-line comments are perfect for adding quick explanations or clarifications to specific lines of code.
-
Multi-line comments: Multi-line comments, also known as block comments, allow us to comment out multiple lines of code or write longer explanations. They are enclosed between
/*
and*/
.Example:
Multi-line comments are useful when writing detailed explanations, documenting functions or classes, or temporarily disabling a block of code.
Instructions
Add a single-line comment just above the existing console.log statement, explaining what it does.
Add a multi-line comment below the existing code, providing a brief description of JavaScript.
Sign up to start coding
Already have an account?
Sign In