While learning JavaScript, having a good understanding of HTML and CSS is definitely a plus point. It's because, with JavaScript, you will be working with web pages and browsers, so an understanding of HTML and CSS will help you manipulate and style web pages.
Besides that, you will also use an IDE (Integrated Development Environment). An IDE is a place where you will write your JavaScript code.
At the current time, Visual Studio Code is the most popular IDE for JavaScript, so try to get familiar with it as you will be using it a lot in the coming days.
Visit
this guide, to download the IDE.
You can also use online IDEs as well, but make sure to run code on your machine to make the most out of this course.
Once the working environment is set up completely, we will write a simple hello world program.
A Hello World Program in JavaScript prints the text Hello World to the console.
For this we will use a HTML file and inside the HTML file, we will add a script tag. We will then write our JavaScript code inside that tag.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World - JavaScript Example</title>
</head>
<body>
<script>
console.log("Hello World");
</script>
</body>
</html>
Explanation - We created a simple HTML5 document. Just focus on the <script> tag inside the body.
There you can find console.log("Hello World"); which prints the output Hello World onto the terminal.
To see the output,
- run this index.html file in your browser
- open the developer tool
- go to the console where you will see "Hello World"
You can see we have successfully completed the Hello World Program in JavaScript. From the next articles, we will use this exact format to write our JavaScript code.