JavaScript Data Types
JavaScript includes data types similar to other programming languages like Java or C#. Data type indicates characteristics of data. It tells the compiler whether the data value is numeric, alphabetic, date etc., so that it can perform the appropriate operation.
JavaScript includes primitive and non-primitive data types as per latest ECMAScript 5.1.
Primitive Data Types
- String
- Number
- Boolean
- Null
- Undefined
Non-primitive Data Type
- Object
- Date
- Array
JavaScript is a dynamic or loosely-typed language because a variable can hold value of any data type at any point of time.
Example: Loosely-typed JavaScript
var myVar = 100;
myVar = true;
myVar = null;
myVar = undefined;
myVar = "Steve";
alert(myVar); // Steve