JavaScript

What is JavaScript?

JavaScript, commonly referred to as JS, is a programming language primarily used for web development. It stands as one of the fundamental technologies of the World Wide Web, along with HTML and CSS. Virtually every website on the internet relies on JavaScript to enhance client-side functionality.

JavaScript is a powerful high-level programming language that empowers web pages to perform a wide range of complex tasks. From displaying interactive maps and animated games to playing music, JavaScript offers limitless possibilities.

Initially limited to web browsers, JavaScript has expanded its domain to empower backend development and standalone applications, thanks to technologies such as Node.js.

While JavaScript shares a name with Java, which is a distinct programming language, they have significant differences between them.

Examples

Example 1: Hello world program

// Hello world example
console.log('hello world');

outputs hello world

Example 2: Add two numbers

let num1 = 5;
let num2 = 6;

let res = num1 + num2;

console.log('The sum of ' + num1 + ' and ' + num2 + ' is ' + res);

outputs The sum of 5 and 6 is 11

Example 3: Change the text in web page

<html>
   <head>
       <title>ExampleHub example page</title>
   </head>
   <body>
      <button id='my_button'>Old</button>
      <script>
         document.getElementById('my_button').innerHTML = "New";
       </script>
   </body>
</html>

outputs web page with a button labeled New

History

One of the first popular browser with graphical interfaces was Mosaic and it was released in 1993. It played important role for the rapid growth of the world wide web. The lead developers of this browser then founded the popular Netscape corporation which released more polished version year later in 1994 called Netscape Navigator.

In the early years, web pages were dull, consisting mainly of static text and images. However, there was a growing demand for interactivity, prompting the Netscape team to develop a new language that would empower developers to create dynamic web pages. Initially named LiveScript, the language underwent a name change to JavaScript upon its release as a component of the new Navigator browser in 1995.

One year later Microsoft released Internet Explorer with it's own implementation of JavaScript called JScript with support of CSS. The both implementations were similar, but they also had some differences which made it difficult for developers to make websites that work well in both browsers.

By the time 2010 rolled around, the programming language had matured significantly. The major web browsers of that era, including Microsoft Internet Explorer, Mozilla Firefox, and Google Chrome, all supported the language with slight variations. This made development across different browsers much more streamlined. Credit must be given to third-party libraries like jQuery and Prototype, which helped bridge the remaining gaps between browser implementations. As a result, these discrepancies became far less noticeable, allowing developers to focus on creating seamless experiences for users.

Conclusion

JavaScript has evolved into one of the most widely used programming languages, enabling developers to create interactive and dynamic web applications. Its continuous development, extensive libraries, and frameworks have solidified its position as a cornerstone of modern web development. Whether you are a beginner or an experienced developer, learning JavaScript can significantly enhance your ability to build powerful and user-friendly web applications.