What is JavaScript?

Most people learning to code start with HTML and CSS. They then move onto JavaScript, the magic third element that makes websites and projects dynamic. This is because JavaScript is the language that allows a website to change based on user input. For example, if a user clicks a button on a webpage that will change the design or content of the page depending on what the user clicked. This is a basic example of what JavaScript can do, but it can be used to add a lot more functionality to webpages.

Firstly, it is important to understand that javascript is not the same as the other programming languages we are familiar with like Python and C++. This is because javascript is not compiled, it is interpreted. This means that when a piece of javascript code is loaded by a browser it is run straight away, line by line. This happens in a special environment called the execution context. The execution context has a call stack and a memory heap.

As each line of javascript is run, the code is parsed by the engine and converted into an abstract syntax tree. This data structure is then used to create machine code that the processor can read. The code is then executed in the engine using the call stack and memory heap.

This is the most common way that web applications are created, and this type of application is typically what you will find when you open a new tab on a browser. It is also the most commonly used language to work with the Document Object Model (DOM).

Another thing to note about javascript is that it is a high-level language. This means that it does not interact directly with a computer’s bare-metal hardware and instead uses the operating system, the memory and garbage-collection to make it work. This is a key reason why it does not have the same performance limitations as many other programming languages.

One of the ways that javascript is made to be high-level is by the use of a special keyword, var. This keyword is used to declare variables that are only available within the block it is declared in. This makes it much easier to write more readable code.

There are other special keywords that can be used in javascript to create even more powerful code. The two most notable are let and const. These are both designed to provide more control over the behaviour of the code. For example, let lets you use a variable that is only available to the function it is declared in, while const enables you to create variables that can not be reassigned. This is a great way to reduce the amount of bugs in your code.