Preparing your workspace
Variables provide names for values that a program needs to read, update, or pass around.
JavaScript provides let, const, and var for declaring variables. Modern JavaScript generally prefers const when a variable does not need reassignment and let when reassignment is necessary. Common primitive data types include string, number, boolean, undefined, null, bigint, and symbol. Objects and arrays are reference values. Understanding types is important because JavaScript performs operations differently depending on the values involved. The typeof operator can help inspect the type of many values, although it has some well-known special cases.
A study platform might store the student's name, completed lesson count, login state, and selected course in variables.
const studentName = 'Aman'; let completedLessons = 5; const isLoggedIn = true; const course = null; completedLessons = 6; console.log(studentName); console.log(completedLessons); console.log(isLoggedIn);
The console prints the student's name, completed lesson count, and login state.