Chapter 2. Writing Your First Program

In This Chapter

  • Adding JavaScript code to your pages

  • Setting up your environment for JavaScript

  • Creating variables

  • Input and output with modal dialog boxes

  • Using concatenation to build text data

  • Understanding basic data types

  • Using string methods and properties

  • Using conversion functions

Web pages begin with XHTML code. This basic code provides the framework. CSS adds decoration to the basic structure, but to make your pages literally sing and dance, you'll need to learn a programming language.

The JavaScript language is a very popular first language, because it's designed to interact with Web pages, and it's already built into most Web browsers. It's reasonably easy to learn, and it's very powerful.

The whole idea of learning a programming language might seem intimidating, but don't worry. Programming isn't really that hard. I show you exactly how to get started in this chapter. You'll be coding like a pro in a very short time.

Becoming a Programmer

JavaScript is a programming language first developed by Netscape communications. It is now standard on nearly every browser. There are a few things you should know about JavaScript right away:

  • It's a real programming language. Sometimes people who program in other languages such as C++ and VB.NET scoff at JavaScript and claim it's not a "real" programming language because it lacks some features. These features (particularly the ability to communicate with the local file system) were left out on purpose to keep ...

Get JavaScript® and AJAX for Dummies® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.