Hello World Master

Tutorials, articles and quizzes on Software Development

Javascript > Articles

Hello world in Javascript

This article is associated with the following course
Introduction to Javascript

Getting started with Javascript is pretty straightforward. One of the great things about working in Javascript is that we don’t need to download a runtime package to get started, we can use the web browser to start working with Javascript

We’re going to create a simple page that logs hello world in the brower’s console.

First let’s create an index.html file. This is where the page in our browser will be located.

In our HTML file, we want to only write hello world. Lets add the basic boilerplate

<!-- index.html -->
<html>
 <head>
 </head>
</html>

Next we want to add a script tag that points to our soon to be created Javascript file. Lets add a script tag inside the head tag, and lets let its resource be ./script.js

<!-- index.html -->
<html>
 <head>
  <script src="./script.js" />
 </head>
</html>

Now let’s create our script.js in the same directory as our index.html file. In our script.js file, write the following line of code

console.log("Hello world");

console.log is what we use to print logs into the console. Inside it, we pass what we call an parameter, and in this case, it contains a string of Hello world.

Now open your index.html file using your browser of choice. You should see a blank page, because we didn’t add anything to our HTML body. Right click the page and select inspect element. Then, click on console, you should see your hello world log.