MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Data Types0%
Study Materials
JavaScript for BeginnersProgress 0%
1.1What is JavaScript?1.2How JavaScript Works in Browser1.3Setting up Environment: VSCode, Live Server
2.1Variables: var, let, const2.2Data Types2.3Comments and Best Practices
HomeTutorialsJavaScript for BeginnersData Types
Comments and Best Practices

Data Types

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study Materials

Every value in JavaScript belongs to a specific data type. Understanding how JavaScript categorizes, stores, and evaluates data types is essential for debugging type coercion and memory references.


1. The Two Major Categories of Data Types

JavaScript divides its data types into two distinct categories:

Visual Architecture Blueprint
+-----------------------------------------------------------------------------+
|                          JAVASCRIPT DATA TYPES                              |
+-----------------------------------------------------------------------------+
|                                                                             |
|  1. PRIMITIVE TYPES (7 Types)              2. REFERENCE TYPES (Objects)     |
|  - Stored directly in the Call Stack       - Stored in the Memory Heap      |
|  - Immutable (cannot be altered in place)  - Mutable                        |
|  - Compared by VALUE                       - Compared by REFERENCE          |
|                                                                             |
|  * string      * number       * boolean    * Object                         |
|  * null        * undefined    * symbol     * Array (Specialized object)     |
|  * bigint                                  * Function (Callable object)     |
+-----------------------------------------------------------------------------+

2. Deep Dive: The 7 Primitive Types

1. string

Textual data enclosed in single quotes '...', double quotes "...", or backticks `` ... ``:

1let name = "Sumit";
2let greeting = `Hello, ${name}!`; // Template literal

2. number

Represents both integers and floating-point numbers (64-bit IEEE 754 floats):

1let age = 25;
2let price = 99.99;
3let negative = -15;
4// Special numeric values:
5let infinity = 1 / 0; // Infinity
6let notANumber = "apple" / 2; // NaN (Not-a-Number)

3. bigint

For arbitrarily large integers beyond JavaScript's safe integer limit ($2^{53} - 1$ or 9,007,199,254,740,991):

1let bigNumber = 9007199254740991123456789n; // Suffix with 'n'

4. boolean

Logical values: strictly true or false:

1let isEnrolled = true;
2let hasPaid = false;

5. undefined

A variable that has been declared, but has not yet been assigned a value:

1let score;
2console.log(score); // undefined

6. null

Represents the intentional absence of any object value:

1let selectedCourse = null; // Deliberately empty for now

7. symbol (ES6)

A unique, immutable identifier used as unique object keys:

1const id1 = Symbol("id");
2const id2 = Symbol("id");
3console.log(id1 === id2); // false (Every symbol is globally unique!)

3. The typeof Operator and the Famous Bug

Use the typeof operator to inspect the data type of any variable:

1typeof "Hello" // "string"
2typeof 42 // "number"
3typeof true // "boolean"
4typeof undefined // "undefined"
5typeof 100n // "bigint"
6typeof Symbol() // "symbol"
7typeof { a: 1 } // "object"
8typeof [1, 2, 3] // "object" (Arrays are objects in JS!)
9typeof function(){}// "function"
Important Warning
[!WARNING] The Famous JavaScript Bug: ```javascript typeof null; // "object" ``` In the original 1995 JavaScript implementation, values were stored with a type tag. The tag for objects was 0. null was represented as a NULL pointer (0x00), causing typeof null to incorrectly return "object". This bug cannot be fixed now because doing so would break millions of legacy websites!

4. Primitives (By Value) vs. Reference Types (By Reference)

Understanding this difference prevents 90% of beginner logic bugs:

Primitives are Copied by Value:

1let a = 10;
2let b = a; // b receives an independent copy of value 10
3b = 20;
4 
5console.log(a); // 10 (Untouched!)
6console.log(b); // 20

Objects are Copied by Memory Reference:

1let user1 = { name: "Sumit" };
2let user2 = user1; // user2 points to the SAME memory address in the heap!
3 
4user2.name = "Rahul";
5 
6console.log(user1.name); // "Rahul" (user1 was modified because both point to same object!)

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
How many primitive data types exist in modern JavaScript?
Question 2
What is the result of running typeof null in JavaScript?
Question 3
What is the difference between undefined and null?
Question 4
What happens when you assign an object variable to a new variable (let obj2 = obj1;)?
Question 5
Which primitive data type allows representing integers larger than $2^{53} - 1$?
Next Lesson

Comments and Best Practices

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Variables: var, let, constComments and Best Practices

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext