Series: JavaScript 101
- About JavaScript 101
- Hello World in Web Browser
- Hello World in Node.js
- Variable in JavaScript
- Data Types in JavaScript
- Array in JavaScript
- Object in JavaScript
- Spread Operator in JavaScript
- Loops in JavaScript
- Conditional Statements in JavaScript
- Functions in JavaScript
- Object-Oriented Programming in JavaScript
Hello World in Web Browser
Welcome to the world of coding!
One of the first things you'll learn as a beginner is the classic "Hello, World!" program 👋🏻.
This program is a simple way to get started with a new programming language and is a rite of passage for all new programmers. In this article, we'll be showing you how to write your first "Hello World" program in JavaScript, and how to run it in the Chrome browser.
Open the developer console
First, let's start by opening the Chrome browser. by following the steps.
- Right-click on a web page and select "Inspect" from the drop-down menu.
- Use the keyboard shortcut Ctrl + Shift + I (Windows) or Cmd + Option + I (Mac).
- Click on the three dots menu in the upper-right corner of Chrome and select "More Tools" > "Developer Tools".
Once you have the developer console open, you will see a prompt where you can type in JavaScript code. This is where you can interact with the JavaScript code on the page and run your own JavaScript code
Write your first program 🦾
To write "Hello World" in JavaScript, all you need to do is type the following into the console.
console.log("Hello world!")
The console.log
function is a built-in function in JavaScript that allows you to print text or variables to the console. In this case, we are passing in the string "Hello World"
as the argument to the function.
Once you press Enter, you will see "Hello World" printed to the console.
🎉 Congratulations, you've just written your first "Hello World" program in JavaScript!