JavaScript computer language

As you may already know, JavaScript is a computer language. A computer language consists of instructions that instruct the computer to perform a specific task. A task could be simple as validating the input on a form, for instance. The computer will perform this task based on the specific instructions (code) we write. In JavaScript, the code is normally processed (or executed) from the top line downward.

In everyday life, we use or process instructions to complete a task although it may not be always obvious. For instance, assume you have a task to visit this site, to perform this task you may follow these steps:

  1. turn ON your machine, if it is not ON
  2. connect to Internet
  3. open your browser
  4. type scriptingmaster.com in the browser's address bar and press enter or click on a link that points to this site.

When writing code in a computer language such as JavaScript, you follow a similar procedure consisting of mini-steps that if completed, complete the main task. For example, if you wanted to show the user the total cost of the products for an online checkout, you may write your code that will:

  1. determine the cost of each item
  2. add and store (in computer's memory) the cost of all items
  3. add tax, if any, to the above cost
  4. add shipping costs, if any, and add it to the above cost
  5. display the final cost to the user

When the written code in JavaScript is executed by a computer, it is converted to a machine code (or simply into binary numbers) because computers do not really understand JavaScript instructions. A special program called interpreter is responsible for "translating" JavaScript code to machine language each time the program (or the code) is run. Thus JavaScript is referred to as a interpreted language.