Learn JS Interactively

JavaScript Variables

JavaScript variables are used to store data values. They can be changed during the execution of a program.

Example: let x = 10;

JavaScript Constants

Constants are like variables, but they cannot be changed once they are declared.

Example: const pi = 3.14;

JavaScript Conditionals

Conditional statements, like if, else, and else if, allow you to make decisions in your code.

Example: if (x > 10) { /* do something */ }

JavaScript Loops

Loops are used to repeatedly execute a block of code. Common loop types include for, while, and do...while.

Example: for (let i = 0; i < 5; i++) { /* do something */ }

JavaScript Functions

Functions are blocks of code that can be called to perform a specific task. They can return values.

Example: function greet(name) { return 'Hello, ' + name; }

JavaScript Arrays

Arrays are used to store multiple values in a single variable. They are indexed and can be modified.

Example: let fruits = ['apple', 'banana', 'cherry'];

JavaScript Strings

Strings are sequences of characters and are used for storing and manipulating text.

Example: let message = 'Hello, World!';

JavaScript Objects

Objects are used to store collections of key-value pairs. They are versatile data structures.

Example: let person = { firstName: 'John', lastName: 'Doe' };

JavaScript ES6 Features

ES6 introduced many new features to JavaScript, including arrow functions, template literals, and destructuring.

Example: const greet = (name) => `Hello, ${name}`;