How to Do Hello World in JavaScript: A Beginner’s Guide

Bobby Jul 13, 2026

Hello, aspiring JavaScript developer! Today, we're going to create a simple yet iconic program: "Hello, World!" in JavaScript. This programming classic is more than just a greeting; it's a rite of passage for every coder. So, let's dive right in, and I promise, by the end, you'll have a glowing "Hello, World!" message to show off.

How Not to Render "Hello World" with JavaScript
How Not to Render "Hello World" with JavaScript

Before we start, make sure you have a code editor ready. If you're new to this, Visual Studio Code, Sublime Text, or even Notepad++ are great options. Also, ensure you have a JavaScript runtime environment like Node.js or a browser console to run your code.

some type of text that is in the language hello world with different types of words
some type of text that is in the language hello world with different types of words

Creating a JavaScript File

First, let's create a new JavaScript file. Name it helloWorld.js, and open it in your favorite code editor.

hello world
hello world

Now that we have our file, it's time to write our first line of code.

Adding the First Line of Code

C# Hello World Program Example - Tutlane
C# Hello World Program Example - Tutlane

In JavaScript, you can output a message using the built-in `console.log()` function. This function is used to display output in the console of your web browser or Node.js runtime.

So, let's use `console.log()` to output our message. Type the following line at the top of your helloWorld.js file:

```javascript console.log('Hello, World!'); ```

Running Your JavaScript Code

an email message with the words,'me i'm good in c language interviewer write hello world using c
an email message with the words,'me i'm good in c language interviewer write hello world using c

Now that we have our code, it's time to run it. If you're using Node.js, open your terminal, navigate to the directory with your helloWorld.js file, and type:

node helloWorld.js

You should see 'Hello, World!' printed in your console.

Hello World: Your First Step in Programming Success 👋
Hello World: Your First Step in Programming Success 👋

If you're using a browser, open the developer tools (right-click > Inspect > Console or press F12 or Ctrl + Shift + I), then paste and enter `console.log('Hello, World!')`. Again, you should see our greeting in the console.

Modifying the Message

What Is JavaScript?
What Is JavaScript?
Every programming journey begins with a simple "Hello World"
Every programming journey begins with a simple "Hello World"
Printing "Hello World"
Printing "Hello World"
an orange and white poster with the words hello, world in different programming languages
an orange and white poster with the words hello, world in different programming languages
Hello, World!
Hello, World!
Here’s How Hello World in 15 Programming/Scripting Languages Looks Like
Here’s How Hello World in 15 Programming/Scripting Languages Looks Like
Pirple.com: Sharpen your skills.
Pirple.com: Sharpen your skills.
the words hello world are written in green and red letters on a black background,
the words hello world are written in green and red letters on a black background,
C++ Hello world program explanation - Code for Java c
C++ Hello world program explanation - Code for Java c
C++ print hello world - First C++ Program Hello World - BTech Geeks
C++ print hello world - First C++ Program Hello World - BTech Geeks
an image of a programming program with the words,'every programming hello world '
an image of a programming program with the words,'every programming hello world '
Hello world in 5 different programming languages
Hello world in 5 different programming languages
"Hello world!" in different programming languages 💀
"Hello world!" in different programming languages 💀
Salutare, lume! eng. Hello, world! - in 12 limbaje de programare - GNU/Linux
Salutare, lume! eng. Hello, world! - in 12 limbaje de programare - GNU/Linux
the word hello - world written in neon green and pink on a black background with arrows
the word hello - world written in neon green and pink on a black background with arrows
Home
Home
Get Started With Web Assembly
Get Started With Web Assembly
C Hello World Program - BTech Geeks
C Hello World Program - BTech Geeks
Hello, World! Iconic Programming Phrase Art
Hello, World! Iconic Programming Phrase Art
Best Way to Learn JavaScript in 2024 (Free and Paid Tutorials)
Best Way to Learn JavaScript in 2024 (Free and Paid Tutorials)

That was fun! But let's make it more personal. Change the code to:

```javascript console.log('Hello, JavaScript World!'); ```

Now, run the code again. Voila! You've just customized your 'Hello, World!' message.

By now, you've written and run your first JavaScript program. Great job! Here's where you can start to explore more about JavaScript, venture into web development, or even build your dream application.

Remember, 'Hello, World!' is just the beginning. The future of what you can create with JavaScript is vast. So, keep coding, keep learning, and happy programming!