Comment: Comment() constructor
The Comment() constructor returns a newly created
Comment object with the optional string given in
parameter as its textual content.
Syntax
js
new Comment()
new Comment(aString)
Parameters
aStringOptional
Return value
A new Comment containing aString, or the empty string if no parameter was given.
Example
js
let comment = new Comment("Test");
Specifications
| Specification |
|---|
| DOM Standard # ref-for-dom-comment-comment① |
Browser compatibility
| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Comment() constructor | |||||||||||
See also
- The DOM interfaces index
Document.createComment()is an outdated alternative to this constructor.