Historically, the HTML comments were used as a hack to hide the code from browsers that didn't understood the `<script>` element. It is not meant to commenting JavaScript code. For example,
```js <script> <!-- foo = bar; baz(); --> </script> ``` browsers that didn't support `<script>` treat its content as an HTML comment, and browsers that do support it ignore the `<!--` and `-->` lines, but certainly not the lines inbetween. —Claude > Le 2 janv. 2016 à 21:56, kdex <[email protected]> a écrit : > > ES2015's annex section B.1.3 (*HTML-like Comments*) currently defines > `Comment` > in a way that makes > > ```js > <!-- This whole line > ``` > > a comment, and likewise for > > ```js > undefined --> everything after the first occurrence of "-->" in this line. > ``` > > However, the tokens `<!--` and `-->` are inherently used as *block* comments > in HTML, whereas EcmaScript doesn't allow them to span over multiple lines. > As > a consequence, > > ```js > <!-- This looks is a comment in HTML, so > shouldn't it behave like a comment in JS, too? --> > ``` > > would result in a syntax error. > > Is this a deliberate choice? Are there reasons for or against matching HTML's > behavior in ES2016? > > Personally, I don't use these tokens anyway, but this seems like an obvious > inconsistency to me. > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

