代码示例:(标识:jsck_document_createcomment)
<!DOCTYPE html>
<html>
<body>

<h1>Document 对象</h1>

<h2>createComment() 方法</h2>

<p id="demo"></p>

<script>
const comment = document.createComment("我的个人意见");
document.body.appendChild(comment);
document.getElementById("demo").innerHTML =
"此文档中添加了评论,但如您所知,评论是不可见的。";
</script>

</body>
</html>
运行结果: