Introduction

JavaScript is a versatile programming language commonly used for web development.

It enables dynamic content, interactivity, and client-side scripting.

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

JavaScript is interpreted by web browsers and can interact with the DOM.

Variables

Variables in JavaScript store data values.

There are three types of variable declarations:

var x = 10; let y = 20; const z = 30;

Use let and const instead of var for better scoping.

Functions

Functions are blocks of reusable code.

They can take parameters and return values.

function greet(name) { return "Hello, " + name; }

Functions help in code organization and modularity.

Loops

Loops allow repeated execution of code.

Common loops in JavaScript:

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

Loops help in handling iterative tasks efficiently.

Objects

Objects in JavaScript are collections of key-value pairs.

They store structured data.

let person = { name: "John", age: 30 };

Objects can have methods and properties.