> appendChild()` in JavaScript
is a "DOM method" used to add (append) an element as the last child of another element in an HTML document.
👉 Syntax of JavaScript:
parentElement.appendChild(childElement);
const image = new Image();
image.src = "media/girl.jpg";
document.body.appendChild(image);
Note: Without appendChild(), the element stays in memory and won’t appear on the page.

Top comments (0)