Chapter 11. Learning JavaScript

There are many programming languages in existence today, and in this chapter, you will begin learning the basics of a programming language called JavaScript, which is by far the most common programming language used in web pages.

Although it is not possible to teach you everything there is to learn about JavaScript in one or two chapters, there are thousands of free scripts available on the Web that you can use. Therefore, the aim of this chapter is to teach you enough to start using these scripts in your web pages and to understand how they work. You should even be able to customize these scripts and write some basic scripts of your own based upon what you will learn in this and the following chapter. In addition, it will serve as a good introduction to general programming concepts.

Once you have covered the basics of JavaScript in this chapter, Chapter 12 will show you lots of examples that should both act as a library of helpful scripts you can use in your own pages and also clarify how the basic concepts you learned in this chapter work in practice.

As you will see, JavaScript gives web developers a programming language to use in web pages that allows them to perform tasks such as the following:

  • Read elements from documents and write new elements and text into documents

  • Manipulate or move text

  • Perform mathematical calculations on data

  • React to events, such as a user clicking a button

  • Retrieve the current date and time from a user's computer or the last ...

Get Beginning HTML, XHTML, CSS, and JavaScript® now with the O’Reilly learning platform.

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