Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Part 2.3Basic output methods in JavaScript

Part 2.3Basic output methods in JavaScript

So far this tutorial has relied on just two methods of output; console.log and console.error. JavaScript provides at least four methods of output. This part of the tutorial will describe two additional methods of output.


The function used thus far have all been highly unobtrusive and do not do anything but allow debugging. The document.write is another very useful debugging output method.

document.write("Hello world!")

Another form of this is the is document.writeln which will write a line to the document:

document.writeln("Hello world!")

Using the document.write and the document.writeln functions will overwrite any existing HTML in the document. and should only be used for debugging purposes.


The most useful output when developing a usable web document that JavaScript provides is the window.alert function.

window.alert("Hello world!")

The window.alert function is a formalised version of the alert function:

alert("Hello world!")
Feedback 👍
Comments are sent via email to me.