The JS or JavaScript is a client-side programming language added to HTML to help developers create user interactive and dynamic web pages.

Although at the beginning JavaScript was mostly used to speed up the HTML form validations, it has grown to be one of the key features in web development and almost every document will have some form of the script embedded inside.

It may be used for the most complex calculations, any kind of user interactions with the page, affecting the document's layout and styles through its own syntax or by using DOM (Document Object Model) interface and, even, affecting the browser behavior via a BOM (Browser Object Model). Nowadays even the mobile browsers have it implemented within their browsers.

A JavaScript syntax maybe be made of only the core language defined by ECMA-262, but more frequently combines the core language with the DOM and / or the BOM. Therefore a complete JavaScript implementation is made of the following parts:

  1. The Core (ECMAScript);
  2. The Document Object Model (DOM) ;
  3. The Browser Object Model (BOM) .

javascript model diagram

Javascript can easily be applied to any structured language document, such as an XML document as well as to a HTML one. For simplicity reasons in this tutorial we are going to refer most of our examples to HMTL only.

 

Example

A basic JavaScript / HTML interaction:

 

›› go to examples ››