Javascript data types

In JavaScript, there are two sorts of data types -

  • Primitive data type
  • Non-primitive (reference) data type

Primitive data type

Data TypeDescription
NumberIntegers or floating-point
StringSeries of one or more charcters
BooleanTrue or False
UndefinedUnassigned values
NullUnknown values

Non-primitive data type

Data TypeDescription
ObjectKey:value pairs
ArrayGroup of similar values

Lets take an example

let value = 16;                                 // Number
let name = "Vishal Torgal";                     // String
let obj = {empId:"1701", empLoc: "Atlanta"};    // Object

JavaScript types are dynamic. For example

let val;           // Now val is undefined
val = "Torgal";    // Now val is a String
val = 5;           // Now val is a Number