JavaScript Guide
JavaScript - client-side scripting
JavaScript is the scripting language of the web!
JavaScript is used by millions of web pages to improve design, validate forms, detect browsers, create cookies, and more.
JavaScript is easy to learn
JavaScript examples
My first JavaScript program
This is a paragraph
Try it »
Click the "Try it" button to view the online example.
What is JavaScript?
- JavaScript is designed to add interactive behavior to HTML pages.
- JavaScript is a scripting language (a scripting language is a lightweight programming language).
- JavaScript consists of several lines of executable computer code.
- JavaScript is usually embedded directly in HTML pages.
- JavaScript is an interpreted language (meaning the code is not precompiled before execution).
- Everyone can use JavaScript without purchasing a license.
Client-side scripting
JavaScript "governs" browser behavior; this is called client-side scripting (or browser scripting).
Server-side scripting "governs" server behavior (see our ASP / PHP tutorials on this site).
What can JavaScript do?
- JavaScript provides HTML designers with a programming tool
HTML authors are often not programmers, but JavaScript is a scripting language with extremely simple syntax! Almost anyone can place small code snippets into their HTML pages. - JavaScript can put dynamic text into HTML pages
A JavaScript statement like this can put variable text into an HTML page: document.write("" + name + "
") - JavaScript can respond to events
JavaScript can be set to execute only when an event occurs, such as when a page finishes loading or when the user clicks an HTML element. - JavaScript can read and write HTML elements
JavaScript can read and change the content of HTML elements. - JavaScript can be used to validate data
JavaScript can be used to validate data before it is submitted to the server. - JavaScript can be used to detect the visitor's browser
JavaScript can be used to detect the visitor's browser and load a corresponding page for that browser based on the detection. - JavaScript can be used to create cookies
JavaScript can be used to store and retrieve information located on the visitor's computer.
What is the HTML DOM?
The HTML DOM defines the standard methods for accessing and manipulating HTML documents.
The DOM represents an HTML document as a tree structure.
HTML DOM Tree example
How to learn JavaScript?
Visit the complete JavaScript tutorial