Variables, Constants and Data Types | Bondar Academy
Course: JavaScript for Testers
Module: JavaScript Fundamentals
Instructor: Artem Bondar
Lesson Summary
In this lesson, we cover variables , constants , and data types in JavaScript, which are fundamental building blocks of programming. Variables Variables are used to hold information during code execution. They can be created using the keywords var or let . For example: var firstName = "John"; let lastName = "Smith"; Variables can hold single or multiple values and can be reassigned. For instance: let age = 5; age = 6; // age is now 6 Think of a variable as a shopping cart that holds items during your shopping trip. Constants Constants are defined using the keyword const and cannot be reassigned once set. For example: const occupation = "Engineer"; If you attempt to change a constant's value, an error occurs: occupation = "Driver"; // Error: Assignment to constant variable Data Types JavaScript has five primitive data types: String : Text enclosed in quotes, e.g., "Hello" Number : Numeric values without quotes, e.g., 25 Boolean : Represents true or false Null : Represents no value Undefined : Indicates a variable that has not been assigned a value In summary, variables can hold and change values, while constants maintain a fixed value. JavaScript supports various data types for different kinds of information.