Friday, February 14, 2020

Data Types In JavaScript

Data Types In JavaScript

Data Types

Data types are built-in data structures and vary from one programming language to another programming language. JavaScript is known for dynamic typing it means that variables in JavaScript are note attached with any particular value type. It means that a JavaScript variable can be assigned any type of value or reassigned some other type of value. We can declare a variable multiple times in a JavaScript code.

var a=10;

The latest ECMAScript standard defines eight data types

JavaScript data types
JavaScript DataTypes

  • Boolean
  • Null
  • Undefined
  • Number
  • BigInt
  • String
  • Symbol
  • Object

The primitive data types in JavaScript are,


The boolean type can have either true or false values.


Null type can have only one value null.


Undefined type,  if a variable is not assigned a value still it has a value known as undefined.


There are two numeric types in JavaScript number and BigInt. The JavaScript Number type is a double-precision 64-bit binary format IEEE E 754 value. The number type is also able to represent floating-point numbers. There are 3 symbolic values associated with the number type known as +infinity, -infinity and NaN(Not a Number).

To watch the minimum and maximum values available for the Number type, we can use Number.MAX_VLAUE and Number.MIN_VALUE.


BigInt primitive JavaScript type can be used to represent the integers with arbitrary precision. The advantage of using BigInt is that we can operate on very large integers even beyond the limits of safe integers provided by the Number type in JavaScript.


JavaScript String data type is used to represent the data in text format we can consider a string as a collection of 16-bit unsigned integer values. Each element in a string contains a position in the string and these positions are known as index please stop the index number it started with Value 0. JavaScript strings are immutable and one cannot be modified once it is created. The length of the string is the number of elements present in it.


Symbols are new types introduced in JavaScript, a symbol is a unique and immutable primitive value. Symbols are generally used as the key to an object's property.


A memory location referenced by some identifier is known as an Object in programming generally. JavaScript objects can have a collection of properties referenced by keys. These keys are associated with some values, and these values can be anything. The keys are always unique.

 var obj={fname:'James', lname:'Bond'};