First JavaScript - "Hello World!"

This section provides the first JavaScript tutorial example - 'Hello World!'.

The best way to learn JavaScript is to embed the JavaScript code in an HTML document and run it in a Web browser. Here is what I did to write and run my first JavaScript code - "Hello World!".

1. Enter the following HTML document with one line of JavaScript:

<html>
<head><title>Hello World!</title></head>
<body>
<script type="text/javascript">
   document.write('Hello World!');
</script>
</body>
</html>

2. Save this HTML document as Hello_World.html.

3. Open Hello_World.html in Web browser. You will see:

Hello World! 

Congratulations, you have created and executed your first JavaScript successfully!

Table of Contents

 About This Book

Introduction to JavaScript

 What Is JavaScript

First JavaScript - "Hello World!"

 Walking through the First JavaScript

 The document.write() Method

 ECMAScript Language Specification and JavaScript Dialects

 Data Types, Variables and Expressions

 Flow Control Statements

 Creating, Accessing, and Manipulating Arrays

 Defining and Calling Functions

 Web Browser Supporting JavaScript

 Server-Side and Client-Side Web Scripting

 Introduction to Objects

 Defining Your Own Object Types

 Inheritance of Properties and Methods through the Prototype Object Chain

 'jrunscript' - JavaScript Shell Command from JDK

 Using Functions as "Function" Objects

 Introduction to Built-in Object Types

 W3C's Document Object Model (DOM) Specifications

 AJAX (Asynchronous JavaScript And XML)

 References

 Full Version in PDF/EPUB