JavaScript is a cross-platform, object-based scripting language. This guide explains everything you need to know about using JavaScript.
New features in JavaScript versions
{{ JSGVersions() }}
What you should already know ?
This guide assumes you have the following basic background:
- A general understanding of the Internet and the World Wide Web (WWW).
- Good working knowledge of HyperText Markup Language (HTML).
- Some programming experience. If you are new to programming, try one of the tutorials linked on the page JavaScript
JavaScript versions
JavaScript version | Navigator version |
---|---|
JavaScript 1.0 | Navigator 2.0 |
JavaScript 1.1 | Navigator 3.0 |
JavaScript 1.2 | Navigator 4.0-4.05 |
JavaScript 1.3 | Navigator 4.06-4.7x |
JavaScript 1.4 | |
JavaScript 1.5 | Navigator 6.0 Mozilla (open source browser) |
JavaScript 1.6 | Firefox 1.5, other Mozilla 1.8-based products |
JavaScript 1.7 | Firefox 2, other Mozilla 1.8.1-based products |
JavaScript 1.8 | Firefox 3, other Gecko 1.9-based products |
Where to find JavaScript information
JavaScript documentation includes the following books:
- JavaScript Guide (this guide) provides information about JavaScript language and its objects.
- JavaScript Reference provides reference material for JavaScript language.
If you are new to JavaScript, start with the JavaScript Guide. Once you have a firm grasp of the fundamentals, you can use the JavaScript Reference to get more details on individual objects and statements.
Tips for learning JavaScript
Getting started with JavaScript is easy: all you need is a modern Web browser. This guide includes some JavaScript features which are only currently available in the latest versions of Firefox (and other Gecko powered browsers), so using the most recent version of Firefox is recommended.
There are two tools built into Firefox that are useful for experimenting with JavaScript: the Web Console and Scratchpad.
The Web Console
The Web Console shows you information about the currently loaded Web page, and also includes a command line that you can use to execute JavaScript expressions in the current page.
To open the Web Console, select "Web Console" from the "Web Developer" menu, which is under the "Tools" menu in Firefox. It appears at the bottom of the browser window. Along the bottom of the console is a command line that you can use to enter JavaScript, and the output appears in the pane above:
Scratchpad
The Web Console is great for executing single lines of JavaScript, but although you can execute multiple lines, it's not very convenient for that, and you can't save your code samples using the Web Console. So for more complex examples Scratchpad is a better tool.
To open Scratchpad, select "Scratchpad" from the "Web Developer" menu, which is under the "Tools" menu in Firefox. It opens in a separate window and is an editor that you can use to write and execute JavaScript in the browser. You can also save scripts to disk and load them from disk.
If you choose "Inspect", the code in your pad is executed in the browser and the result is inserted back into the pad as a comment:
Document conventions
JavaScript applications run on many operating systems; the information in this book applies to all versions. File and directory paths are given in Windows format (with backslashes separating directory names). For Unix versions, the directory paths are the same, except that you use slashes instead of backslashes to separate directories.
This guide uses uniform resource locators (URLs) of the following form:
https://server.domain/path/file.html
In these URLs, server represents the name of the server on which you run your application, such as research1
or www
; domain represents your Internet domain name, such as netscape.com
or uiuc.edu
; path represents the directory structure on the server; and file.html
represents an individual file name. In general, items in italics in URLs are placeholders and items in normal monospace font are literals. If your server has Secure Sockets Layer (SSL) enabled, you would use https
instead of http
in the URL.
This guide uses the following font conventions:
The monospace font
is used for sample code and code listings, API and language elements (such as method names and property names), file names, path names, directory names, HTML tags, and any text that must be typed on the screen. (Monospace italic font
is used for placeholders embedded in code.)- Italic type is used for book titles, emphasis, variables and placeholders, and words used in the literal sense.
- Boldface type is used for glossary terms.