Introduction

JavaScript is a programming language used to create interactive effects within web browsers.

It is one of the core technologies of the World Wide Web.

console.log("Hello, world!");

JavaScript code can be embedded directly into HTML pages.

Variables

Variables are used to store data values.

You can declare variables using var, let, or const.

let x = 10; const y = 5;

Use `let` for variables that will change, `const` for ones that won’t.

Functions

Functions are blocks of code that perform a particular task.

They are executed when called or invoked.

function greet() { console.log("Hello!"); }

You can pass parameters to functions for dynamic behavior.

Loops

Loops are used to run a block of code repeatedly.

Common types include for, while, and do...while.

for (let i = 0; i < 5; i++) { console.log(i); } while (condition) { /* code */ }

Loops help automate repetitive tasks.

Arrays

Arrays store multiple values in a single variable.

They can hold elements of any type.

let fruits = ["apple", "banana", "cherry"];

JavaScript provides many built-in methods for arrays.