DEV Community

Cover image for JavaScript : A Simple “Hello World”
Ibrohimbek Alisherov
Ibrohimbek Alisherov

Posted on

JavaScript : A Simple “Hello World”

JavaScript: A Simple “Hello World”
So, you’ve decided to dive into the world of web development? Fantastic choice! And where does virtually every web developer’s journey begin? With a simple, humble program that does one thing: it says “Hello World!”.

This tradition is a rite of passage. It’s your first step into a larger universe, testing that your tools are working and that you understand the basic syntax of a new language. For us, that language is JavaScript — the language of the web.

What is JavaScript?
In a nutshell, JavaScript is what makes websites dynamic and interactive. While HTML structures a page (like the walls of a house) and CSS styles it (like the paint and furniture), JavaScript adds behavior (like the electricty and plumbing that make the house functional). It can update content, animate images, validate forms, and so much more.

Your First JavaScript Program
Let’s write our “Hello, World!” program. We’ll do it in a way that’s easiest for beginners: right in the web browser.

Open your browser (Chrome, Firefox, etc.).

Right-click anywhere on a blank page and select Inspect

Click on the Console tab. You should see a blank area with a > prompt. This is the JavaScript console, where we can write and run code directly.

Now, type the following line and press Enter:
console.log(“Hello, World!”);

You should se this immediately printed out below your code:
Hello, World!

Congratulations! You’ve just written your first JavaScript program.

What Just Happened?
Let’s break down that single of code:

console: This is an object that gives you access to the browser’s debugging console

. log: This is a method (an action) of the console object. Its job is to log or output whatever you put inside the parentheses to the console.

(“Hello, World!”): This is the parameter we are passing to the log method. The quotation marks tell JavaScript that this is a piece of text (a string)

So, put together, console.log(“Hello, World!”); is a command that says: “Hey browser, please print the text “Hello, World!” to the console.”

What is Next? This is just the beginning. From here, you’ll learn about variables to store data, functions to perform actions, and how to connect JavaScript to buttons and forms on an actual webpage. The possibilities are endless.

Remember, every expert developer started exactly where you are now — with a simple “Hello, World!. Keep experimenting, keep building, and most importantly, have fun.

Article by Ibrohim Bek | MERN Stack Developer
ibrohimbek.link

Top comments (0)