Site icon i2tutorials

Javascript-First Program

Javascript-First Program

 

Hello World: Writing Your First JavaScript Program

 

“Hello World” is a staple of programming courses. The objective of this program is simple: output the text “Hello World” on your computer screen. Because of the simplicity of the message and syntax, it is usually the first program taught to beginners.

 

Writing a “Hello World” program in JavaScript code, as we will learn, is exceptionally easy and requires not more than 3 lines of code.

 

What You’ll Need:

 

Since JavaScript is interpreted by the browser itself. We don’t need any fancy compilers / additional software to write JS programs. All you need is:

text editor: Notepad will do just fine, but we highly recommend Notepad++ (free).

web browser: You can use anything you want – Google Chrome, Firefox, Internet Explorer and Safari.

 

Getting Started: Creating the HTML Framework:

 

First, create a simple HTML file where we can include our JavaScript code.

Open your text editor and type the following code into it:

 

<!DOCTYPE HTML>
<html>
<head>
<title>JavaScript Hello World</title>
</head>
<body>
<h1>JavaScript Hello World Example</h1>
</body>
</html>

 

Save this file as test.html

 

OUTPUT:

 

 

Exit mobile version