Table of content
- Setup and Installation
- Hello World in Console
- Hello World in Alert
- Variables in Hello World
- Functions in Hello World
- Arrays in Hello World
- Objects in Hello World
The Hello World program is a simple code example used to introduce beginners to programming. It is traditionally the first program a programmer writes and simply displays the text "Hello, World!" on the screen. Although it is a simple program, it is important because it teaches you the basic syntax of a programming language, as well as the process of running and executing code.
Setup and Installation
Step 1: Install a text editor.
Step 2: Install a web browser.
Step 3: Create an HTML file.
Step 4: Write your first "Hello World" program.
This code displays an alert box with the message "Hello World" when the HTML file is opened in a web browser.
Step 5: Save and run your code.
Hello World in Console
To do this, we start by opening a text editor and creating a new file. We can name the file "hello-world.js". Then, we write the following code:
This code uses the "console" object to print the text "Hello World!" to the console. The console is a tool that allows us to interact with our programs and view the output they produce.
Once we've written our code, we save the file and open a console application of our choice. In most browsers, we can open the console by pressing the F12 key, which opens the Developer Tools. Selecting the Console tab will show us where the output of our program will be displayed.
To execute our "Hello World" program in the console, we navigate to the directory where our "hello-world.js" file is located and run the command:
This will execute our program and display the output "Hello World!" in the console.
Hello World in Alert
To display "Hello World" using Alert, follow these steps:
- Open a text editor and create a new file with the .html extension.
- Add the necessary HTML code to create a simple web page.
- Add a