Docsity

Introduction to JavaScript: A Beginner's Guide, Summaries of Java Programming

Partial preview of the text

Download Introduction to JavaScript: A Beginner's Guide and more Summaries Java Programming in PDF only on Docsity!

Introduction to

JavaScript

Topics 

What is JavaScript?

Why JavaScript?

Including JavaScript in HTML

Hello World Example Script

JavaScript Comments

JavaScript is not Java 

Completely different types of languages thatjust happen to be similarly named 

JavaScript - programs are interpreted in thebrowser



Java - programs are compiled and can be run asstand alone applications

Why JavaScript? 

It’s easier to learn than most programminglanguages

It allows you to make interactive Web pages

It can be fun!

Hello, World! 

Typically, in any programming language, thefirst example you learn displays “Hello,World!”

We are going to take a look at a Hello Worldexample and then examine all of its parts.

Hello World in JavaScript

Hello World Example

The tag 

The code for the script is contained in the

tag

Hiding JavaScript from OlderBrowsers 

Some older browsers do not support JavaScript



We need to tell those browsers to ignore what is in the

document.write()

document.write("Hello,world!");

Enclosed in quotes --

denotes a "string"

Ends in a semicolon

Comments in JavaScript 

Two types of comments 

Single line 

Uses two forward slashes (i.e.

//

)



Multiple line 

Uses

/*

and

*/

Multiple Line CommentExample

Find the Bug!^