files/en-us/web/api/characterdata/data/index.md
{{APIRef("DOM")}}
The data property of the {{domxref("CharacterData")}} interface represent the value of the current object's data.
A string with the character information contained in the {{domxref("CharacterData")}} node.
When set to the null value, that null value is converted to the empty string (""), so cd.data = null is equivalent to cd.data = "".
[!NOTE] {{domxref("CharacterData")}} is an abstract interface. The examples below use two concrete interfaces implementing it, {{domxref("Text")}} and {{domxref("Comment")}}.
<!-- This is an HTML comment -->
<output id="result"></output>
const comment = document.body.childNodes[1];
const output = document.getElementById("result");
output.value = comment.data;
{{EmbedLiveSample("Reading_a_comment_using_data", "100%", 50)}}
<span>Result: </span>Not set.
const span = document.querySelector("span");
const textNode = span.nextSibling;
textNode.data = "This text has been set using 'textNode.data'.";
{{EmbedLiveSample("Setting_the_content_of_a_text_node_using_data", "100%", 50)}}
{{Specifications}}
{{Compat}}