Data Type in JavaScript
Data types are an essential concept in programming languages like JavaScript. They define the type of data that can be stored and manipulated in a program. Understanding data types is crucial for writing efficient and bug-free code. Let's explore the different data types in JavaScript:
Video Explanation

1. Primitive Data Types:
These are the basic building blocks of data.
String:
- A sequence of characters.
- Defined with single (' ') or double (" ") quotes.
let greeting = "Hello, World!";
-
Template Literals / Template strings
- A special type of strings created using backticks(`)
let info = `Know more about Template Literals`;- Allows multi-line strings
let example = `This is an applicationof template literalsin JavaScript `;- Allows string interpolation :- Template literals allow embedding variables and expressions directly into strings using '$'
let num = 7,name = "Kim";let interpolatedString = `${name}'s lucky number is ${2 * num}`;//Kim's lucky number is 14
Number:
- Represents both integers and floating-point numbers.
- No distinction between integers and floats.
let age = 25;
let price = 19.99;
Boolean:
- Represents either
trueorfalse.
let isStudent = true;
Undefined:
- Variable declared but not assigned.
let undefinedVar;
Null:
- Represents the intentional absence of any object value.
let nullVar = null;
Symbol (ES6 and later):
- Provides a unique value, often used as identifiers.
let id = Symbol("id");
2. Composite Data Types:
These are used to store collections of data.