Data Types in JavaScript

In this JavaScript tutorial, we are going to learn about data types in JavaScript.

What are Data Types?

  • In JavaScript, Data type defines that which type of value can be stored in a variable.

  • There are two types of Data Types in JavaScript:

    • Primitive (predefined)

    • Reference/Derived (defined by the programmer)

Primitive Types

JavaScript primitive types refer to the basic or fundamental types of data that can be used to represent simple values. There are seven primitive types in JavaScript and these are:

  • Number: Numer data type is used to represent numeric values, including integers and floating-point numbers. (for e.g. 4, 20)
const num = 35;

  • String: Strings are used to represent textual data, such as a sequence of characters. (for e.g. "Raju", "Geeks Help")
const str = "Geeks Help";

  • Boolean: It is used to represent a boolean value, which can be either true or false. (for e.g. true, false)
const isDeveloper = true;

  • Undefined: It represents a value that is not yet defined or initialized. (a specialized value for uninitialized variables.)
let name;

  • Null: The null data type is used to represent a value that is explicitly empty or non-existent. (a unique value that symbolizes a lack of value)
const agent = null;

  • Symbol: Symbol in JavaScript are used to represent a unique and immutable value.
const firstName = Symbol('Raju');
const lastName = Symbol('WebDev');


  • BigInt: BigInt is a new numeric data type that can represent integers with arbitrary precision. 
const bigNum = 9007199254740991n;

Reference Types

Reference types in JavaScript are complex data types that are composed of a collection of values and properties. And reference types can hold more complex data than primitive types. In JavaScript, reference types are:

  • Object: JavaScript object represents a collection of key-value pairs, which can include properties and methods.

let user = {
    name: "Raju",
    lastname: "WebDev",
    isDeveloper: true,
    age: 20

console.log(typeof user);

  • Array: Array represents an ordered collection of values, which can be of any data type.

let courses = ['HTML Simplified', 'CSS Master', 'JavaScript Doctory', 'ReactJS Ninja'];

  • Function: Functions are reusable blocks of code that can be called by other parts of the program.

function greet() {
    console.log('Hello Developer, Good Morning');


Note: In upcoming tutorials, we will learn about Array, Object and Functions.


Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad

Ads Section