Most text coding languages has a special symbol which tells it to ignore a part of the code. This is useful for when you want to leave small notes for yourself.
// this is a comment only for a single line
alert("Back to code.");
/*
* this comment can go for multiple lines
* see?
*/
alert("Back to code again.");
Like above, you can make a single line comment by using two slashes (//
), whatever happens after those slashes gets ignored by JavaScript. They’re useful for writing small details about your code.
There are also multiple line comments, which start with /*
and end with */
. These are useful when you want to explain big chunks of code.
Text coding sometime gets complicated and leaving comments explaining what’s happening usually helps in making sense of any code you’ve left behind.
Try It Out