<ul></ul>DocumentFragment / notebook
DocumentFragment
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const ul = document.querySelector("ul");
const fruits = ["Apple", "Orange", "Banana", "Melon"];
const fragment = new DocumentFragment();
for (const fruit of fruits) {
const li = document.createElement("li");
li.textContent = fruit;
fragment.append(li);
}
ul.append(fragment);