0% found this document useful (0 votes)
12 views3 pages

JavaScript Data Types Explanation

JavaScript has two main types of data: primitive and non-primitive. Primitive data types include String, Number, Boolean, Undefined, Null, Symbol, and BigInt, while non-primitive data types include Object, Array, and Function. Each type serves different purposes, such as holding single values or collections of values.

Uploaded by

edulearnsin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

JavaScript Data Types Explanation

JavaScript has two main types of data: primitive and non-primitive. Primitive data types include String, Number, Boolean, Undefined, Null, Symbol, and BigInt, while non-primitive data types include Object, Array, and Function. Each type serves different purposes, such as holding single values or collections of values.

Uploaded by

edulearnsin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JavaScript Data Types – Brief

Explanation
JavaScript supports two main types of data:

1. Primitive Data Types


2. Non-Primitive (Reference) Data Types

1. Primitive Data Types


These hold a single value. They are immutable (cannot be changed).

a. String

Represents a sequence of characters.

let name = "John";

b. Number

Represents integers or floating-point numbers.

let age = 25;


let price = 99.99;

c. Boolean

Represents true or false.

let isOnline = true;

d. Undefined

A variable declared but not assigned any value.

let x;
console.log(x); // undefined

e. Null

Represents no value or empty.

let y = null;

f. Symbol (ES6)
Used to create unique identifiers.

let sym = Symbol("id");

g. BigInt (ES11)

Used for very large numbers.

let big = 1234567890123456789012345678901234567890n;

2. Non-Primitive (Reference) Data Types


These store collections of values.

a. Object

Stores key-value pairs.

let person = {
name: "Alice",
age: 30
};

b. Array

Stores a list of items.

let colors = ["red", "green", "blue"];

c. Function

A block of code that can be executed.

function greet() {
return "Hello!";
}

Summary Table
Type Example
String "Hello"
Number 123, 45.67
Boolean true, false
Undefined let x;
Null let y = null;
Symbol Symbol("id")
BigInt 1234567890n
Object {name: "Tom", age: 20}
Array [1, 2, 3]
Function function sayHi() {}

You might also like