JS is a powerful tool that can be used on the client and server side to make your web pages more interactive. With JS, you can create animated images, add text to a page and refresh content on the fly. It also can be used to handle user input such as credit card data, or to display autocomplete suggestions as the user types in a search box.
When a web page is opened, the browser’s interpreter reads the JS code and finds where it can run it on the relevant HTML elements within that page. Then the JS travels through that element family tree or DOM to access, modify, add or delete those elements.
While JS can be used to build web applications, it’s primarily used for making web pages more interactive and engaging. This is where JS’s power shines, and why so many UI Frameworks are built with it, such as React, Angular, Vue, and Ember.
JS is non-blocking and offloads long-running tasks to a separate thread. This feature is useful when you want to execute a task like loading a file on a server, but you don’t want to block the browser from performing other actions.
It is also an excellent language for building games and other applications that require high-performance functionality. It has a large number of libraries that make development even faster and easier.
There are a few different data types that are important to know when learning to program with JS. These include string, int, float, and date.
Variables are containers for values of any data type. They hold values such that when you use them, they have the value that you’ve declared in them.