As with any language, comments are important. There are two ways to declare comments in JavaScript:
const addOne = (val) => { return ++val } // I am an inline, single line comment
// I am a single comment
/*
I am a multiline comment
*/
So, we can start a comment with // and write text until the end of the line. We can have a full-line comment with // and we can also have a multiline comment with /*, ending with */. Additionally, you may encounter comments in the JSDoc style, used for inline documentation:
/**
* Returns the argument incremented by one
* @example
* // returns 6
* addOne(5);
* @returns {Number} Returns the value of the argument incremented by one.
*/
More information on JSDoc is included in the Further reading section.