First JavaScript program

JavaScript programs can be written using various editors. Such as Notpad, MS-fornt page, etc.

Let us take a simple example to print out “Hello World”.

First open Notepad, and type the following code in it and save it as .html extension.

Then open the web browser and load the file from browser’s menu and check the result.

Program:
<!doctype html>
<html>
<head>
<title> first program </title>
<body>
<script language="JavaScript" type="test/JavaScript">

document.write("Hello World");

</script>
</body>
</html>
Result out:
 Hello World

It is a simple html document that includes JavaScript code. Here <script> tag in place in the <body> section.

There is one statement document.write() that is used to print the output. Here write() is a method of the document object.

Leave a Reply