JSFiddle - React, Tailwind, and code Playground
JavaScript
console.clear();
var div = document.createElement("div");
var testStr = "Foo & Bar & Baz < Buz £ ";
var textNode = document.createTextNode(testStr);
function printInfo (msg) {
console.log("====", msg, "====");
console.log(" - There is", div.childNodes.length, "child of type", div.firstChild.nodeType);
console.log(" div.textConent:", div.textContent);
console.log(" div.nodeValue:", div.firstChild.nodeValue);
console.log(" div.innerHTML:", div.innerHTML);
}
div.appendChild(textNode);
printInfo("text node", div);
div.textContent = testStr;
printInfo("textContent", div);
div.nodeValue = testStr;
printInfo("nodeValue", div);
div.innerHTML = testStr;
printInfo("innerHTML", div);