Today I started learning the basics of JavaScript. One of the topics covered in class was Data Types.
Data types tell us what kind of value we are working with in JavaScript.
What are Data Types?
A data type defines the type of data stored in a variable.
For example:
let name = "Jeevish";
let age = 21;
let isStudent = true;
Here:
- "name" is a String
- "age" is a Number
- "isStudent" is a Boolean
Types of JavaScript Data Types
- String
A String is used to store text.
let name = "Jeevish";
- Number
Number is used to store numbers.
let age = 21;
let price = 99.50;
- Boolean
Boolean has only two values:
let isStudent = true;
let isWorking = false;
- Undefined
A variable that is declared but does not have a value is "undefined".
let course;
console.log(course);
- Null
"null" represents an intentionally empty value.
let result = null;
- BigInt
BigInt is used for very large integer values.
let bigNumber = 12345678901234567890n;
- Symbol
Symbol is used to create unique values.
let id = Symbol("id");
- Object
Objects are used to store related data as key-value pairs.
let student = {
name: "Jeevish",
age: 21
};
Conclusion
Learning data types is an important first step in understanding JavaScript. Today I learned how different types of values are represented and stored in JavaScript.
I will continue learning JavaScript step by step and improve my web development skills. 💻
Top comments (0)