Skip to main content

Command Palette

Search for a command to run...

JavaScript : Data Types

Kinds of data JavaScript can handle.

Updated
•2 min read•View as Markdown
JavaScript : Data Types
S

I am person with keen interest in Application Development and making them live into production. I worked on technologies like HTML, CSS, JavaScript, React.js, Express.js. I am good at reading and writing documentation. I have good analytical thinking to solve a particular problem effectively at low cost.

I worked as Site Reliability Engineer at TCS. Though my role, I worked closely with developers and understood the whole software development life cycle from converting the client requirement into code and going through various stages of testing (QA, Beta, Canary) and finally deploying it to production and this cycle continues.

I am open for Web Developer Roles.

To contact me : subhamsahu1120@gmail.com

What are data types?

The data types are just categorizations of data into different types depending upon various use cases. Javascript categorizes data into two types.

  1. Primitive - Immutable values

    • number

    • string

    • boolean

    • bigInt

    • null

    • undefined

    • symbol

  2. Object - Anything which is not primitive.

Number

Integers or floating point numbers. In JavaScript, primarily they are defined using Number Literals.

Examples: 123, 12.3

Note: BigInt is an extension of the Number data type with high precision.

String

Text data. In JavaScript, strings are primarily defined using String Literals.

Examples: "Hello" 'Hello'

Boolean

Logical values - True or False also called Boolean Literals. Booleans are usually used in combination with control statements like if-else, for loop, switch etc.

Null and Undefined

These are special values used in different use cases. The most common use case is to use them as a pre-initialized value for a variable.

null indicates the absence of an object value, which could be defined later.

undefined indicates the absence of a primitive value, which could be defined later.

Object

Objects are mutable, unlike primitive values. We define an object in the form of key & value pairs. Each pair is called a property. Where a property key could be any valid JavaScript identifier. A property value could be any valid JavaScript datatype including objects.

Example

{
    key1:"Hello"  //string as value
    key2:123      //number as value
    key3:true     //boolean as value
    key4:{ }      //object as value
}

Property value could be a function also ( in JavaScript functions are callable objects), we call them methods.

{
    firstName:"Subham",                       
    lastName:"Sahu",
    getFullName: function () {                // method
        return this.firstName + this.lastName;
    }    
}

For you to explore.

Learn about,

  1. symbol data type.

  2. typeof Operator.

What Next?

  • What are other ways to define each data type?

  • Can we convert one data type to another?

JavaScript

Part 4 of 5

In this series of JavaScript, I explained JavaScript programming concepts in a very simple manner, without introducing any Alien terms.

Up next

JavaScript : Array

A widely used data structure in programming world.