Variables and Data Types
BeginnerIn JavaScript, variables are containers for storing data values. JavaScript uses the var, let, and const keywords to declare variables.
Variable Declaration
// Using var (old way, not recommended)
var name = "John";
// Using let (block-scoped, can be reassigned)
let age = 25;
// Using const (block-scoped, cannot be reassigned)
const PI = 3.14;
Data Types
JavaScript has several data types:
- String: Textual data (e.g., "Hello World")
- Number: Numeric data (e.g., 42, 3.14)
- Boolean: True or false values
- Object: Collections of key-value pairs
- Array: Ordered lists of values
- Null: Intentional absence of any object value
- Undefined: Variable that has not been assigned a value
Tip: Always use const by default, and only use let when you know the variable's value will change. Avoid var in modern JavaScript.
Course Lessons
1
Introduction to JavaScript
Completed
2
Variables and Data Types
Current Lesson
3
Operators and Expressions
Locked
4
Control Flow
Locked