Create a constant variable named birthYear with the value 1995.
Variables are containers for storing data values. They allow you to label and reference data in your program. In JavaScript, variables can be declared using var
, let
, or const
.
Example:
let name = "Alice";
Example:
let age = 25;
const pi = 3.14159;
JavaScript has several data types, divided into primitive types and objects.
true
or false
Objects store collections of key-value pairs, arrays, and functions.
Example:
let user = { name: "Alice", age: 25 };
Variables declared with let
or var
can be reassigned:
let score = 10;
score = 15;
Variables declared with const
cannot be reassigned.