What is JavaScript? How does it work

JavaScript is one of the most important programming languages on the web. It is a widely used scripting language to make web pages more interactive.
Published on:
16/11/2023
Javascript
Author:
Norbert Vercauteren
Author:
Norbert Vercauteren
Next blog
Arrow

What is JavaScript?

In addition to HTML and CSS, JavaScript is one of the most important programming languages on the world wide web. It is a widely used scripting language (*) to make web pages more vibrant and interactive.

(*) A scripting language is a programming language that is suitable for writing small programs to perform common or one-off tasks.

What does JavaScript do?

JavaScript can update and change HTML and CSS programs. It can make calculations, manipulate and validate data. The programming determines whether all of this happens automatically or is triggered by an action by the visitor. The latter means that an action by the visitor triggers the execution of the script and causes an “event” on the web page.

For example: When the visitor clicks or hovers over a button, colors on the web page change, or texts are rolled out (>>> read more, menu dropdown), pop-ups appear or animations or effects are started. Or after entering numbers, calculations are made...

With HTML and CSS alone, that's not possible and a web page remains rigid and unchangeable.

Javascript Coding Macbook

JavaScript is client-side

Like HTML and CSS, JavaScript is a “client-side” scripting language. This means that the script is downloaded as code to the visitor's browser and executed there. This is in contrast to “server-side” scripts such as PHP. That's where the processing takes place within the server. Only after the code is executed, the result is downloaded to the visitor's browser.

JavaScript, AJAX, and JSON

AJAX stands for Asynchronous JavaScript And XML. It is a combination of JavaScript and XMLHttpRequest and is used to design interactive web pages that asynchronously retrieve requested data from the web server. As a result, such pages do not have to be refreshed in their entirety. This makes an instant dynamic interaction with the visitor possible.

JSON stands for JavaScript Object Notation. It is a standardized data format. JSON originally grew out of the JavaScript programming language, but is now a language-independent data format. JSON uses human-readable text in the form of data objects that consist of one or more attributes with associated values. It is primarily used to exchange data between the server and the web application, as an alternative to XML.

Although AJAX is still widely used, modern implementations are increasingly making use of JSON.

Javascript, Java

The programming languages of JavaScript and Java are often confused because the name and syntax are very similar. That resemblance, however, is superficial. They are very different languages.

The differences between Java and Javascript

  • Java is a programming language. Javascript is a scripting language.
  • Java is server-side, JavaScript is client-side.
  • Java code must be compiled before you can use it. Javascript is just plain text.
  • Java applications can run in both a virtual machine and a browser. Javascript code only runs in a browser.
  • A compiled Java program gets the extension .class. A Javascript has the extension .js.
  • Java was developed by Sun Micro Systems, JavaScript by Netscape.