JS Output
JavaScript can display data in different ways.
JavaScript has four ways to display output. The most useful and common is innerHTML — it lets you update any element on the page without a full reload.
Try It — Output Methods Compared
Preview
Output Methods Compared
| Method | Where Output Goes | Best For |
|---|---|---|
innerHTML | Inside an HTML element | Displaying HTML content |
textContent | Inside an element (text only) | Safe text updates |
document.write() | Directly in HTML stream | Quick testing only |
window.alert() | Browser popup | Simple alerts |
console.log() | Browser DevTools (F12) | Debugging |
Tip: Open your browser’s DevTools (press F12 → Console tab) to see the
console.log()output from the JS editor!