DEV Community

Srijan
Srijan

Posted on • Originally published at hackinbits.com

What are the different datatypes in Javascript?

This post first appeared on hackinbits.com

The data types in javascript can be divided as Primitive and Object.

Primitive Data Types:

In Javascript, all values except Objects are defined as immutable values (values that cannot be changed or modified). There is a total of 6 primitive types defined by the latest ECMAScript standard:

  1. boolean
  2. null
  3. undefined
  4. number
  5. string
  6. symbol(new in ECMAScript 2015)

Object Data Type:

Object type refers to a compound value that can be seen as a collection of properties. Properties are key/value pairs. Keys are strings (or Symbols) and values can be of any type, including other objects.

var obj = {
  name: 'Cheese Burger',
  cost: 5,
  extra_cheese: true
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)