Welcome Guest! (App Version 3.1)

websitnero logo name

Data Types

Data types are the main building blocks of any computer language. These are basically the formats to store data in the form of variables.

There are 7 data types in JavaScript which can be broadly classified into 2 groups:

Primitive: This includes 6 of the data-types:

  1. Boolean
  2. Null
  3. Undefined
  4. Number
  5. String
  6. Symbol (ECMAScript 6)

Non-Primitive: This includes 1 data-type:

  1. Object

Primitive Values:

As we have already seen all the values of data-types excluding object are immutable (which means, they cannot be changed). Consider the following:

  • String: When you set a string in a variable try adjusting or replacing individual charactes in the string; you'll find this doesn't work. Thus, attempting to set an individual character won't work.
  • Number: Number will have value between -2^53-1 and 2^53-1. It cannot have value out of this range.
  • Boolean: will always represent logical entry and can have either of 2 values: true or false.
  • Null: type has exactly one value: null.
  • Undefined: It represents a variable not assigned any value. Value is 'undefined'.
  • Symbol: This data-type is new to JavaScript. Symbol is unique and immutable pritive value which might be used as key of an Object Property.
Primitive Data Types
1String"Peter"Represents a string like name or address
2Number81Represents a number or a variable like age or marks in a subject
3BooleantrueRepresents one of the 2 options, either, true or false.
4NullnullRepresents null
5UndefinedundefinedRepresents a variable not assigned any value, so default comes with undefined
6SymbolsymbolAdded in ECMA6, with the new data type.

Non-Primitive Value

An Object is only 'Non-Primitive' data type and its values are mutable or changeable. Object is a collection of properties which can be changed at times. Object helps to contain complex data in a single entity with the help of its properties. Easiest way to make object is using object literal initializing it with limited set of properties. Later while coding and making functions, properties may be added or removed to it as per requirement.

Non-Primitive Data Type
1Object{name:"Peter", age:29}Often represents real world objects in the format of key value pair.
WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.