JavaScript Tutorial


JavaScript which is also known as JS is a programming language for the web.  It is a powerful language that enables interactivity with HTML content on web pages.

JavaScript is easy to implement because it is integrated with HTML and available on all browsers. It is open and cross-platform, compatible with most popular browsers. It executes on client (browser) and reduces network traffic.

JavaScript is not compiled but interpreted. The JavaScript Interpreter (embedded in the browsers) is responsible to translate/interpret the JavaScript code.

Why learn JavaScript?

JavaScript is one of the 3 languages all web developers must learn:

  1. HTML to write the content of web pages
  2. CSS to specify the layout and look and feel of HTML
  3. JavaScript to program the behavior of web pages, validate form inputs, provide rich and instant GUI

Where is JavaScript used?

JavaScript is used to create interactive websites. It is mainly used for:

  • Client-side validation
  • Dynamically populate controls (drop-down menus, checkboxes)
  • Displaying popup windows and dialog boxes (like alert dialog box, confirm dialog box and prompt dialog box)
  • Event responders to respond to any user event such as button click or drop down select or mouse hover
  • Call other websites using ajax and http REST api, process data and display the results


This JavaScript tutorial has been designed for beginners to help them understand the basic functionalities.


For this tutorial, it is assumed that the reader have a prior knowledge of HTML coding along with some CSS. It would help if the reader had some prior exposure to object-oriented and functional programming concepts and a general idea on creating simple web pages and online applications.

A typical JavaScript program

Download the code  Run the code

You type your javascript code inside <script> and </script> tags. The script tags can go inside header or body of the HTML.

<!DOCTYPE html>

<h1>JavaScript Exmple</h1>

<p id="demo"></p>

<h2>Welcome to JavaScript</h2>  
document.write("Hello JavaScript tutorial readers");  

When the above page is rendered by a browser, it will understand that all content inside the script tag is Javascript. The optional type=”text/javascript” indicates the browser that the code is in JavaScript language. You can omit the type as the default type for all browsers is JavaScript.

The browser will now invoke the JavaScript engine (interpreter ) and executes the code line by line. The outcome of the above program will be a line of text written to document element.

The document element is the root of the DOM (document object model) available in all browsers. DOM provides a structure to the document and provisions a way for the browser and its JavaScript engine to access/change the style and content of the elements of the document structure.


JavaScript Advantages and Disadvantages >>>
Copyright 2005-2016 KnowledgeHills. Privacy Policy. Contact .