JavaScript Hello World

🧠 The First Step in JavaScript

Writing "Hello World" is a classic tradition for learning any programming language. In JavaScript, it’s your first step toward building interactive web pages and apps. Let’s learn how to do it in different environments!

>>“Every expert was once a beginner who printed Hello World.” 💬

🔤 1. Hello World in Browser Console

This is the simplest way to get started with JavaScript — right in your browser!

Using DevTools Console

console.log("Hello, World!");

Note

💡 Open your browser, press F12 or Ctrl + Shift + I, go to the Console tab, and paste the code to see the message.

🌐 2. Hello World in HTML File

You can include JavaScript inside an HTML file using the <script> tag. This is great for beginners learning how JavaScript interacts with web pages.

hello.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello JS</title>
  </head>
  <body>
    <h1>Hello from HTML!</h1>
    <script>
      console.log("Hello, World from script!");
    </script>
  </body>
</html>

Note

📌 Save this file as hello.html and open it in any browser. Then check the browser console for the message!

🖥️ 3. Hello World with Node.js

If you have Node.js installed, you can run JavaScript outside the browser using your terminal or command prompt.

hello.js

// hello.js
console.log("Hello, Node.js World!");

Then run it using:

Terminal Command

node hello.js

Note

🛠️ This is how backend JavaScript (with Node.js) typically works — no browser required!

🎉 What Just Happened?

  • console.log() is a built-in function that prints messages to the console
  • It's used for debugging, checking values, and displaying text
  • The message appears in the browser’s developer console or in your terminal (Node.js)

🚀 Next Steps

  • ✅ Try editing your message: console.log("Hello, YourName!");
  • ✅ Create a function to greet someone
  • ✅ Learn how JavaScript interacts with HTML elements (DOM)

📚 Helpful Resources

🧠 Summary

Writing “Hello World” is your initiation into JavaScript development. Whether it’s in a browser, HTML file, or Node.js terminal, it shows you how to write and execute your first line of code. From here, the entire JavaScript universe awaits you! 🌌

>>“The journey of a thousand lines of code begins with a single console.log().” 🚀