Preparing your workspace
JavaScript is a programming language used to add logic, interaction, dynamic updates, and application behavior to web pages and applications.
HTML provides structure and CSS controls presentation, while JavaScript adds behavior. JavaScript can respond to user actions, change page content, validate forms, work with APIs, manage application state, and perform calculations. It can run in browsers and also in environments such as Node.js. JavaScript is dynamically typed, which means variables do not need a fixed type declaration. Modern JavaScript includes features such as modules, promises, async and await, classes, destructuring, and many useful built-in methods.
When a user clicks a button and a menu opens without reloading the page, JavaScript is usually handling that interaction.
const button = document.querySelector('#helloButton');
button.addEventListener('click', () => {
alert('Hello!');
});Clicking the button opens an alert saying 'Hello!'.