Walking through the First JavaScript

This section provides a walkthrough of the first JavaScript - 'Hello World!'.

Now let's walkthrough our first JavaScript, "Hello World!", provided in the previous section:

1 <html>
2 <head><title>Hello World!</title></head>
3 <body>
4 <script type="text/javascript">
5    document.write('Hello World!');
6 </script>
7 </body>
8 </html>

The first 3 lines are normal HTML tags.

Line 4 has a special HTML tag <script> that starts a section of JavaScript code. Notice that the type="text/javascript" attribute indicates that the script contained in the tag is a JavaScript.

Line 5 is the only JavaScript statement in this HTML document, which calls the write() function of the built-in object "document". This call will output the string "Hello World!" into the HTML document.

Line 6 ends the JavaScript code.

When the Web browser processes this HTML document, it will interpret all JavaScript statements within the <script>.

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


 PDF Printing Version