JavaScript is a versatile and powerful programming language commonly used in web development. It allows developers to create dynamic and interactive web pages.
- Intro to JavaScript : Learn about the basics of JavaScript, including variables, data types, and operators.
- Data Types : Explore the different data types in JavaScript, such as strings, numbers, and booleans.
- Data Structures : Discover built-in data structures like arrays, objects, maps, and sets.
Basics Practice: JavaScript Basics Practice
JavaScript has several data types that can be divided into two categories: primitive and non-primitive.
- String: Represents textual data. Example:
"Hello, World!" - Number: Represents numeric values. Example:
42 - Boolean: Represents logical values. Example:
trueorfalse - Undefined: Represents a variable that has been declared but not assigned a value.
- Null: Represents the intentional absence of any object value.
- Symbol: Represents a unique and immutable value, often used as object keys.
- BigInt: Represents integers with arbitrary precision. Example:
1234567890123456789012345678901234567890n
- Object: Represents a collection of key-value pairs. Example:
const person = { name: "John", age: 30 };
- Array: Represents an ordered list of values. Example:
const numbers = [1, 2, 3, 4, 5];
JavaScript provides several built-in data structures to manage collections of data.
Arrays are used to store multiple values in a single variable. They are zero-indexed and can contain elements of different data types.
const fruits = ["Apple", "Banana", "Cherry"];Objects are used to store collections of key-value pairs. Keys are strings (or Symbols), and values can be any data type.
const car = {
make: "Toyota",
model: "Corolla",
year: 2020
};Maps are collections of key-value pairs where keys can be of any data type.
const map = new Map();
map.set("name", "Alice");
map.set("age", 25);Sets are collections of unique values.
const set = new Set();
set.add(1);
set.add(2);
set.add(3);