Explained | What is_

What is JavaScript?

Whenever you visit a website today, you can be sure that somewhere behind the scenes JavaScript was involved.

This is true in particular if there is anything going on at the site such as content updating, moving elements or interactive buttons. JavaScript is mainly used for adding functionality to websites but can be used in other areas as well.

This is JavaScript

JavaScript is a scripting or programming language. As with any programming language, it is used by the programmer to give the computer instructions. When creating a website you usually need a few different things, but the three basics are HTML, CSS and JavaScript. HTML is used to describe the structure such as title, image or button. CSS is used to style and position the elements in the structure like the title should be green, the link should be underlined or the image should always stay at the top of the page. JavaScript is used to add behaviour to the website, such as opening and closing menus or adding items to a shopping cart. It can allow users to interact with it, for example, by sending responses from a form to a receiver, or by displaying or hiding content when the user clicks a button or scrolls through a gallery of images.

What is JavaScript used for?

All modern browsers can use JavaScript, so it's no surprise that it's the most commonly used programming language for websites. It's used for creating web and mobile apps, building web servers, developing server applications, and game development (amongst other things). In basic terms, it allows you to transform static pages into interactive pages, enhancing the user experience.

Since JavaScript is so widely used, there are a lot of frameworks, tools and packages around that can make life easier for you. A framework is simply a platform for developing software applications. Think of it as the foundation on which you can build programs. The basics have already been developed and are ready for you to use, which saves you so much time! Common frameworks include React, AngularJS and Vue, to name a few.

How does JavaScript work?

The browser knows how to read JavaScript and what to do with it. So, when you visit a website, the browser fetches all the things it needs to display the website to you in a way you are familiar with. Then, it runs the JavaScript in your browser. This is different, for example, from a program that you would install on your computer. JavaScript can also be used on the server, and for many other things.

Try it for yourself

JavaScript is easy to get started with, but you should know some basics before you begin. There are some things you can create straight up in JavaScript, such as variables and functions. In short, a variable is a container where you can store data values, such as a line of text (known as a 'string'), or a number. A function is a block of code that's been designed to execute a specific task.

You can play around in Playcode or JSfiddle.

One way to declare a variable in JavaScript is:

const catName = ‘Ms. Fussy’;

A function is something that is executed. A function can be declared like this:

function feedCat() {
// do something
}

Combine these:

var catName = ‘Ms. Fussy’;
function feedCat() {
console.log(catName + ‘ it’s time to eat!’);
}

and execute the function by calling it:

feedCat();

Now you will have told the computer to print “Ms.Fussy it’s it’s time to eat!” in the console 😸. See this code live on JSFiddle too, here.

Continue learning

Mini Camp

Learn JavaScript and APIs in just 9 weeks.

Read more

Bootcamp

Remote Frontend Bootcamp

Read more

Article

What do I need to start coding?

Read more