---
title: "What are the different data types in JavaScript and how to determine the type of a variable?"  
description: "What are the different data types in JavaScript and how to determine the type of a variable?"  
author: "Revati S Misra"  
published: 2023-07-16  
updated: 2023-07-17  
canonical: https://www.mindstick.com/forum/159118/what-are-the-different-data-types-in-javascript-and-how-to-determine-the-type-of-a-variable  
category: "javascript"  
tags: ["javascript", "variable"]  
reading_time: 2 minutes  

---

# What are the different data types in JavaScript and how to determine the type of a variable?

What are the different [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) types in [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) and how to determine the type of a [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation)?

## Replies

### Reply by Aryan Kumar

JavaScript has seven primitive data types:

- **String** - A sequence of characters.
- **Number** - A number, either integer or floating-point.
- **Boolean** - A value of true or false.
- **Null** - A value that indicates that a variable has no value.
- **Undefined** - A value that indicates that a variable has not been assigned a value yet.
- **BigInt** - A 64-bit integer.
- **Symbol** - A unique identifier.

In addition to these primitive data types, JavaScript also has objects, which are complex data structures that can contain any combination of primitive and object types.

The type of a variable is determined by the value that is assigned to it. For example, if you assign the string "Hello, world!" to a variable, the type of the variable will be "string".

You can use the `typeof` operator to determine the type of a variable. For example, the following code will print the type of the variable `myVar`:

```plaintext
const myVar = "Hello, world!";
console.log(typeof myVar); // "string"
```

The `typeof` operator can also be used to determine the type of an object. For example, the following code will print the type of the object `myObject`:

```plaintext
const myObject = {
  name: "John Doe",
  age: 30,
};
console.log(typeof myObject); // "object"
```

Here is a table that summarizes the different data types in JavaScript and how to determine their type:

| Data type | Value | `typeof` operator |
| --- | --- | --- |
| String | A sequence of characters | "string" |
| Number | A number, either integer or floating-point | "number" |
| Boolean | A value of true or false | "boolean" |
| Null | A value that indicates that a variable has no value | "null" |
| Undefined | A value that indicates that a variable has not been assigned a value yet | "undefined" |
| BigInt | A 64-bit integer | "bigint" |
| Symbol | A unique identifier | "symbol" |


---

Original Source: https://www.mindstick.com/forum/159118/what-are-the-different-data-types-in-javascript-and-how-to-determine-the-type-of-a-variable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
