Dashboard

  • JavaScript Tutorial

  • Introduction
  • JavaScript is a programming language that executes on the browser. It turns static HTML web pages into interactive web pages by dynamically updating content, validating form data, controlling multimedia, animate images, and almost everything else on the web pages.

  • These tutorials will help you learn JavaScript step by step starting from the basics to an advanced level. These tutorials are broken down into sections where each section contains a number of related topics that are packed with easy to understand explanations, real-world examples, tips, notes and useful references.

  • Each tutorial includes practical examples. You can edit and see the result real time with Code Editor. Click on 'Try it' button at the bottom of each example to edit and see the actual result in the browser. Click Next to start learning JavaScript.
  • JavaScript Test Test your JavaScript knowledge with a quick test. It includes 20 questions and each question includes 4 options. Select an appropriate answer out of 4 options. There is no time limit for this test.
  • What is JavaScript
  • JavaScript is a programming language that executes on the browser. It turns static HTML web pages into interactive web pages by dynamically updating content, validating form data, controlling multimedia, animate images, and almost everything else on the web pages. JavaScript is the third most important web technology after HTML and CSS. JavaScript can be used to create web and mobile applications, build web servers, create games, etc.
  • JavaScript Example
  • JavaScript can be used in various activities like data validation, displaying popup messages, handling events of HTML elements, modifying CSS, etc. The following sample form uses JavaScript to validate data and change the color of the form.

  • JavaScript History

    The responsive UI and menu of this website is also using JavaScript. There is no website in this world that does not use JavaScript or JavaScript-based frameworks.
  • JavaScript History

    In early 1995, Brendan Eich from Netscape designed and implemented a new language for non-java programmers to give newly added Java support in Netscape navigator. It was initially named Mocha, then LiveScript, and finally JavaScript. Nowadays, JavaScript can execute not only on browsers but also on the server or any device with a JavaScript Engine. For example, Node.js is a framework based on JavaScript that executes on the server.
  • JavaScript History

    The responsive UI and menu of this website is also using JavaScript. There is no website in this world that does not use JavaScript or JavaScript-based frameworks.
  • JavaScript and ECMAScript

    Often you will hear the term ECMAScript while working with JavaScript. Let's clear the confusion before it arises. As you now know, JavaScript was primarily developed to execute on browsers. There are many different browsers from different companies. So, there was a need to standardize the execution of the JavaScript code to achieve the same functionality in all the browsers.
  • JavaScript and ECMAScript

    Ecma International is a non-profit organization that creates standards for technologies. ECMA International publishes the specification for scripting languages is called 'ECMAScript'. ECMAScript specification defined in ECMA-262 for creating a general-purpose scripting language. JavaScript implements the ECMAScript standards, which includes features specified in ECMA-262 specification as well as other features which are not based on ECMAScript standards. There are different editions of ECMAScript. Most browsers have implemented ECMA-262 5.1 edition.
  • JavaScript Engine

    avaScript engine interprets, compiles, and executes JavaScript code. It also does memory management, JIT compilation, type system, etc. Different browsers use different JavaScript engines, as listed in the below table.
  • ,.......
  • Setup JavaScript Development Environment

  • Here, we are going to use JavaScript in developing a web application. So, we must have at least two things, a browser, and an editor to write the JavaScript code. Although we also need a webserver to run a web application, but we will use a single HTML web page to run our JavaScript code. So, no need to install it for now.
  • Browser

  • Mostly, you will have a browser already installed on your PC, Microsoft Edge on the Windows platform, and Safari on Mac OS. You can also install the following browser as per your preference:

  • Microsoft Edge, Google Chrome, Mozilla FireFox, Safari, Opera
  • IDEs for JavaScript Application Development

  • You can write JavaScript code using a simple editor like Notepad. However, you can install any open-sourced or licensed IDE (Integrated Development Environment) to get the advantage of IntelliSense support for JavaScript and syntax error/warning highlighter for rapid development. The followings are some of the well-known JavaScript editors:
  • JavaScript Example

  • Visual Studio Code (Free, cross-platform)
  • Visual Studio Code (Free, cross-platform)
  • Eclipse (Free, cross-platform)
  • Atom (Free, cross-platform)
  • Notepad++ (Free, Windows)
  • Code Lobster (Free, cross-platform)
  • WebStorm (Paid, cross-platform)
  • Online Editors for JavaScript

  • Use the online editor to quickly execute the JavaScript code without any installation. The followings are free online editors:
  • jsfiddle.net
  • jsbin.com
  • playcode.io
  • HTML script Tag

  • The HTML script tag script is used to embed data or executable client side scripting language in an HTML page. Mostly, JavaScript or JavaScript based API code inside a script tag. The following is an example of an HTML page that contains the JavaScript code in a script tag.


  • In the above example, a tag contains the JavaScript alert('Hello, how are you?') that display a message box. HTML v4 requires the type attribute to identify the language of script code embedded within script tag. This is specified as MIME type e.g. 'text/javascript', 'text/ecmascript', 'text/vbscript', etc. HTML v5 page does not require the type attribute because the default script language is 'text/javascript' in a script tag. An HTML page can contain multiple script tags in the 'head' or 'body' tag. The browser executes all the script tags, starting from the first script tag from the beginning. Scripts without async, defer or type="module" attributes, as well as inline scripts, are fetched and executed immediately, before the browser continues to parse the page. Consider the following page with multiple script tags.
  • JavaScript Example

  • Above, the first script tag containing alert('Executing JavaScript 1') will be executed first, then alert('Executing JavaScript 2') will be executed, and then alert('Executing JavaScript 3') will be executed. The browser loads all the scripts included in the 'head' tag before loading and rendering the 'body' tag elements. So, always include JavaScript files/code in the 'head' that are going to be used while rendering the UI. All other scripts should be placed before the ending "/body" tag. This way, you can increase the page loading speed.
  • ......
  • Reference the External Script File

  • A script tag can also be used to include an external script file to an HTML web page by using the src attribute. If you don't want to write inline JavaScript code in the 'script '/script' tag, then you can also write JavaScript code in a separate file with .js extension and include it in a web page using 'script' tag and reference the file via src attribute.

  • Above, the 'script' src="/MyJavaScriptFile.js"> points to the external JavaScript file using the src="/MyJavaScriptFile.js" attribute where the value of the src attribute is the path or url from which a file needs to be loaded in the browser. Note that you can load the files from your domain as well as other domains.
  • Global Attributes

  • avaScript engine interprets, compiles, and executes JavaScript code. It also does memory management, JIT compilation, type system, etc. Different browsers use different JavaScript engines, as listed in the below table.