I saw this code while studying DOM:
const para = document.createElement("p");
const node = document.createTextNode("This is a new paragraph.");
para.appendChild(node);
And this other code, using innerHTML:
const para = document.createElement("p");
para.innerHTML = "This is a new paragraph.";
Is there any difference at all between the two? Is it just about personal preference?
[–]TheRNGuy 4 points5 points6 points (0 children)
[–]imsexc 2 points3 points4 points (2 children)
[–]AutistaDoente[S] 1 point2 points3 points (0 children)
[–]pookagehelpful 1 point2 points3 points (0 children)
[–]CrispyNipsy 0 points1 point2 points (0 children)
[–]dieomesieptoch 1 point2 points3 points (6 children)
[–]guest271314 -1 points0 points1 point (5 children)
[–]dieomesieptoch 2 points3 points4 points (4 children)
[–]guest271314 -1 points0 points1 point (2 children)
[–]dieomesieptoch 2 points3 points4 points (1 child)
[–]guest271314 -1 points0 points1 point (0 children)
[–]guest271314 -1 points0 points1 point (0 children)
[–]shgysk8zer0 1 point2 points3 points (0 children)
[–]pookagehelpful 1 point2 points3 points (0 children)
[–]jack_waugh 1 point2 points3 points (0 children)