DEV Community

Jeevish
Jeevish

Posted on

Understanding JavaScript Data Types: A Beginner's Guide

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

  1. String

A String is used to store text.

let name = "Jeevish";

  1. Number

Number is used to store numbers.

let age = 21;
let price = 99.50;

  1. Boolean

Boolean has only two values:

let isStudent = true;
let isWorking = false;

  1. Undefined

A variable that is declared but does not have a value is "undefined".

let course;
console.log(course);

  1. Null

"null" represents an intentionally empty value.

let result = null;

  1. BigInt

BigInt is used for very large integer values.

let bigNumber = 12345678901234567890n;

  1. Symbol

Symbol is used to create unique values.

let id = Symbol("id");

  1. 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)