0

I know that JavaScript single line comments start with // and end on a line break, multi-line comments start with /* and end with */, and that HTML comments start with <!-- and end with -->.

What I didn't knew is that apparently starting a JavaScript line with --> creates a single line comment (that ends on a line break).

// can be used in front of code but for --> to work it can't have any running code behind:

console.log('Start'); // normal comment
--> weird comment
/*
  Can't have running code at the start
  of the line or it throws the error:
  Uncaught SyntaxError: Unexpected token >
  (but it can have space characters)
*/
console.log('End');

My question is if this is normal behavior or just some glitch, since I found no information on it.
It's definitely connected with the HTML comment block/tag, probably unintended and/or a glitch.

Tested with the Google Chrome browser in a HTML file and on the developer tools' console.

user7393973
  • 2,270
  • 1
  • 20
  • 58

0 Answers0