What is JavaScript?

What is JavaScript?

JavaScript is a scripting language commonly used in web browsers in order to make content interactive (and it is not related to the Java programming language). JavaScript is not the only language used to make content interactive (since some interactive content relies solely on CSS and CSS variants); however, it seems to be the majority of interactive content relies (at least partially) on JavaScript. JavaScript was developed by Brendan Eich (link to his website can be found here) in April 1995.

During February 2009, the first commit to Node.js was committed to Github by Ryan Dhal (link to his website can be found here) which can be seen on Github. Since that first commit to Node.js, the Node.js platform has grown to allow JavaScript to run on multiple operating systems. If you want to learn more about what Node.js is, please see my post "What is Node.js". Due to the creation and adoption on Node.js, JavaScript has become more popular than ever.

Since JavaScript is a scripting language, it does not need to be compiled to run, which can be good or bad depending on what you are trying to do. Compiled code is often more optimized for specific operating systems; however compiled code is often readable to humans. If you wanted to make a simple program in JavaScript you could write something similar to:

let a = 5;
let b = 7;

console.log(a + b);
Addition in JavaScript

In the code snippet above, let a = 5; saves the value of 5 to the variable a in memory. Likewise let b = 7;save the value of 7 to the variable b in memory. Running the code above would output 12 since 5 plus 7 equals 12.

Though JavaScript on its own is fairly robust it is often used along side HTML (or inside of a framework such as Node.js) to alter the content on websites since the original purpose of JavaScript was to modify webpages.

If you wanted to change the text of a bare-bones website you could do:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    
  </body>
  <script type="text/javascript">
    document.getElementsByTagName('body')[0].innerHTML = 'text';
  </script>
</html>
Basic Website

Which would result in a mostly empty webpage that has text in the upper left-hand corner of the webpage and nothing else.

If you want to learn more about JavaScript I recommend you look at the documentation from Mozilla here. JavaScript can be run inside the browser, so, there should not be any need to download additional software.