DEV Community

bryancasler
bryancasler

Posted on

TIL: HTML Comments are valid inside Javascript

<script type="text/javascript">
// This is a valid comment
<!-- This is a valid comment too
<!--
function message() {
  alert("Hello World!")
}
//-->
</script>

The two forward slashes at the end of comment line (//) is the JavaScript comment symbol. This prevents JavaScript from executing the --> tag. - w3schools

REF: https://github.com/denysdovhan/wtfjs#html-comments-are-valid-in-javascript

Top comments (0)