What is JavaScript

The JavaScript is a light-weight programming language that is generally used at the client side. Today’s modern browsers like Google Chrome, Firefox, IE, Safari etc. support JavaScript.

The JavaScript is used to make static web pages (HTML) interactive. You can include JavaScript (JS) code into HTML page or refer JS files to run JavaScript code and perform desired activities without requesting a server. The client side refers to a browser running a web page.

You can perform general programming stuff like using variables, decision-making statements (if, switch), loops (for loop, while, do while etc.) Similarly, you can use advanced programming features like JavaScript array, string, date formatting, other built-in useful methods provided by JavaScript in web pages.

All that code will be executed at the client side i.e. browser that is running your web page.

This is really a useful thing, otherwise, you have to send a request to the server to perform operations that can be done quickly and without increasing load at the server.

Similarly, JavaScript can be used to make a website more interactive like adding drop-down menus, drag n drop features and many other interactive things.

JavaScript form authentication is also quite useful, where you do not need to submit information before validation. All validation can be done by using javascript.

You can also use JavaScript at the server side.

About JavaScript Tutorial

In this tutorial, you will learn basic programming features like declaring and using variables, if else statements, switch statement, for and while loops etc. The tutorial also covers advanced features like arrays, string methods, date formatting and other useful JavaScript features.

You can also see hands-on examples to see JS code online along with running the demos in this JavaScript tutorial. Just click at “Experience this online” to see JS code along with how it works in almost each tutorial.

A few quick examples of JavaScript

These are a few online examples from different tutorials:

JavaScript if else example

A for loop example

HTML button onclick example

getElementById example to set textbox value

JavaScript innerHTML example to set div content

Redirect example

JavaScript alert example

A confirm dialog example

Chapters in this Tutorial

Following topics are covered in this tutorial of JavaScript. You can also see these tutorials at left side navigation across.

  • JS Tutorial
  • The if statement
  • The Switch statement
  • JavaScript For loop
  • The while loop
  • JavaScript forEach
  • Custom Functions
  • JavaScript Events
  • Javascript Array
    • array length
    • array push
    • remove array
    • array splice
    • array slice
    • array sort
    • array indexOf
    • array to string
    • forEach
  • JavaScript String
    • JavaScript substring
    • String substr
    • String replace
    • String slice
    • Trim
    • String Length
    • The Split
  • JavaScript Methods / Properties
    •  JavaScript getelemenetByID
    • innerHTML
    •  window.location
    •  window.location.href
    •  setTimeout
    •  setInterval
  • JavaScript Date and Time
    • JavaScript date
    • Date format
    • The time
  • JavaScript Alerts
    • Alerts
    • JavaScript Confirm box
    • JavaScript Prompt