Explore the Glossary:
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |


Get new entries to your inbox:

JavaScript (JS)

JavaScript (often abbreviated to "JS") is a programming language that is used widely to extend the functionality and interactivity of web pages, either instead of or more often as well as HTML and CSS. JavaScript is a scripting language, which means that it is used to write scripts that are executed by a web browser.

The word "Javascript" on a yellow background, with a stylised computer screen depicting some code.
kehey74, CC BY-SA 4.0, via Wikimedia Commons

JavaScript was first created in 1995 by Brendan Eich while he was working at Netscape Communications Corporation. It was known under a couple of names - Mocha, then LiveScript - before it settled into the name JavaScript. It was designed to be a simple language that could be easily integrated into web pages.

It is now an essential component of modern web development, commonly used to add interactivity to web pages. Such interactivity includes responding to user input and changing the content of the page dynamically. It can also be used to create complex web applications, such as online games and social media platforms.

The following text is an example of what a relatively simple section of JavaScript might look like within the code of a website:

<button onclick="myFunction()">Click this button to see a simple example of JavaScript in action!</button>

<p id="date">
    <script>
        function myFunction() {

            let d = new Date();
            alert("Today's date is " + d);
        }
    </script>
</p>

The bit that begins with <button onclick... and ends with </button> is actually a piece of html rather than JavaScript. It tells a browser that is loading the page to show a clickable button at that point in the web page, and also what to do if the button is clicked. In this example, "myfunction()" tells the browser (when the button is clicked) to run a function called "myFunction" which is defined just below, between the <script> and </script> tags, which are there to tell the browser that that bit is JavaScript rather than html.

In fact, the example code above is included in the html that your browser is reading and using to display this website properly. This is how your browser has interpreted the <button onclick... bit:

And if you click on it, you'll experience how your browser interprets the script itself. If all has gone according to plan, you'll see a pop-up message that displays the data and time right now (clear it by clicking "OK", and try again later to see that the time in the message has changed)! This script was created with inspiration from "How To Add JavaScript to HTML" and "onclick Event".

One of the most significant advantages of JavaScript is that it is a client-side scripting language, which means that it runs on the user's computer rather than on the web server. This allows JavaScript to create a more responsive and interactive user experience, as it does not require the web server to process every user input. JavaScript can also be used in conjunction with server-side scripting languages, such as PHP and Python, to create more complex web applications.

To use JavaScript, all you need is a web browser that supports the language, which all modern web browsers, including Google Chrome, Mozilla Firefox, and Microsoft Edge, do. You do not need any special software or tools to start learning JavaScript, as you can write JavaScript code directly into a text editor before saving and loading it as a webpage.

Next steps:

  1. Explore some examples of JavaScript being used in the wild. This post from Creative Bloq lists websites that use the coding language in a variety of ways.
    • Another example is this tool that I created for museum educators and other freelancers to help them decide what rates to charge. The page and visuals of the tool are written in html and embedded in a normal blog post, but if you inspect the post's code you'll find some javascript behind the scenes that does calculations based on what a user inputs into the number fields. Feel free to play with it: just change the numbers in the white input fields. you can't break it and nobody else will see what you input (unless they're looking over your shoulder).
  2. Two free tools that can help you start learning more about JavaScript are this JavaScript tutorial (from W3 Schools), and this introduction to JavaScript (by Codeacademy).

Further reading:

Comments

Related Posts

Popular Posts

Explore the Glossary:        | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |