Home JavaScript Hello World Program in JavaScript

Hello World Program in JavaScript

Beginner ⏱ 5 min read Updated: Jul 2026
  • A Hello World program is the first program beginners write in any programming language
  • It displays a simple message like "Hello World" on the screen
  • In JavaScript, we can display messages using methods like console.log()
  • It helps beginners understand JavaScript syntax and program execution

What is Hello World Program in JavaScript?

A Hello World program in JavaScript is a simple program that prints the text "Hello World" as output. It is usually the first step for beginners to learn how JavaScript code is written and executed.

JavaScript can display output in different ways. The most common method is using the console.log() function, which prints messages in the browser console.

Simple Hello World Program Using console.log()

The console.log() method is used to display output in the browser console. It is mainly used for testing and debugging JavaScript code.

Example

console.log("Hello World");
        
Result
Hello World

Example Explained

console

It is a built-in object in JavaScript that provides access to the browser console.

log()

It is a method used to display messages or values in the console.

"Hello World"

It is a string value that will be displayed as output.

Hello World Program Inside HTML

JavaScript is commonly used with HTML. We can add JavaScript code inside the <script> tag to run it in a web browser.

Example

<!DOCTYPE html>
<html>
<body>
<script>
console.log("Hello World");
</script>
</body>
</html>
        

Displaying Hello World on Web Page

JavaScript can also change HTML content and display output directly on a webpage using DOM manipulation.

Example

<h1 id="demo"></h1>
<script>
document.getElementById("demo").innerHTML = ("Hello World");
</script>
        
Result

Hello World

Why Learn Hello World Program?

Writing a Hello World program helps beginners understand the basic structure of JavaScript code. It introduces important concepts like statements, functions, output methods, and how JavaScript runs in a browser.

💡 Note: Every JavaScript developer starts with a simple Hello World program before learning advanced concepts like variables, functions, objects, and frameworks.