JavaScriptJavaScript

The Programming language of the web

JavaScript is mainly run in the browser, but can run on servers and any other place today.

Need to know (before learning JavaScript): HTML, CSS

Connecting HTML and JavaScript

To insert JavaScript code in an HTML page we use the <script> tag. The two options are to write the JavaScript code inside the tag or link to a JavaScript file with a url.

JavaScript variables are used to save some value or data to reuse it later. Declaring and using a variable is easy since you don't need to specify the type.

Making conditions helps to decide what your code will do next. For these case we use if, else and switch statements.

Functions are blocks of code you can declare to call (execute) later at the right time. They are very useful in order to reuse specific code actions.

Many times you will find that you want to go over an array list or values of an object. There are many ways to do loops and we'll cover the basic ones here.

To make websites interactive you might want to change the page by adding different styles or showing different data. To do that we fetch the element (html tag) that we want to change and make our changes on it.

Every tag on the page has many events that you can listen to and assign a function to be called when that event happens. Some of the basic ones are click (a left click of the mouse on the tag), hover, keydown (when a user clicks a key on the keyboard) and many more events.

Fetching data is very common on the web, whether it is data that you show on the page like text or numbers or something else you need to show something to users. Often in JavaScript when fetching data, promises are in use.

You can simply open this URL https://jsonplaceholder.typicode.com/users in the browser and see the data that is being returned.

Many times you would find other people wrote a library (code) that you could use to build your website. A bit of searching online with the text 'html', 'css' or 'javascript' you could find a lot of useful libraries, tools, widgets and many documentation of how to implement other people's code to help you out. The community is great and everyone uses other people's code inside of their own websites to develop stuff faster and easier. It is common to find many articles explaining how to do things with different libraries, even though they are not connected to the official library documentation. One example is having a map on your site with the leafletjs library. If you're interested in further learning about this particular library, go to https://leafletjs.com/examples/quick-start/