create comments in Javascript
Code snippet on how to create comments in Javascript
// Comments in Javascript are denoted by two slashes //
// Anything after the two slashes is a comment and is not evaluated by the browser when the code runs
// Example:
console.log('Hello World'); // This line prints 'Hello World' to the console
The code above shows how to create comments in Javascript. First it begins with two slashes //, followed by the comment. Anything after this is not evaluated by the browser when the code runs.
An example of a comment is shown after the first two lines; it explains that the line beneath it prints out ‘Hello World’ to the console. Any comments after this line would be ignored. Comments are a great way to add explanations for code, making it easier for other developers to understand.