
JavaScript
JavaScript Comments
JavaScript comments are explanatory notes for JavaScript code. They are used for code testing and temporarily prevent code execution.
Single Line Comments
A single-line JavaScript comment begins with / /. A code that is not meant to be executed is written between or at the end of / / lines. JavaScript does not read the code following a comment. Therefore, it will not be executed.
Multi-line Comments
It is also used in JavaScript to prevent a function or multiple lines from executing. These comments have /* and */ at the beginning and the end, respectively. JavaScript ignores any text between these symbols.
Why are JavaScript Comments Used?
The sole purpose of using JavaScript comments is to prevent code execution. The simple addition of lines / / followed by text converts a code into a comment. This means it will no longer be an executable line.
Sometimes, a multi-line comment is also used to stop a function. It is suitable for code testing and stops function execution by adding text between /*… */