05. Three ways to print

Before we move on, let's look at the three ways we can print out some output. This will be helpful for you to use when trying to understand what is going on when your JavaScript is processes.

Writing out as an alert

An alert window is a small window popup. We can display text on it with the alert() command.

Writing onto document

To write onto our document (or within the browser), we use the document.write() function. We'll learn all about the document object in an upcoming lesson.

Writing out to console

Every browser has a JavaScript console. In Chrome, for example, you can access it by going to View, Developer, JavaScript console. To write out onto this console, use console.log().

Thus, we have three ways to output text:

alert("Hello world!");
document.write("Hello world!");
console.log("Hello world!");

As you go through this tutorial, it's important to try out what you learned on your own, and use one of the three ways to check your outputs.

Build modern and responsive webpages

Responsive Typography

Build modern and responsive webpages Try Front-end

Responsive web design helps your site maintain its design integrity on a variety of screen sizes, but how does it affect your typography? With this practical book, graphic designers, web designers, and front-end developers alike will learn the nuts and bolts of how to get the best appearance from type without sacrificing performance on any device.

$ Check price
24.9924.99Amazon 4.5 logo(3+ reviews)

More Front-end resources

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Ad