JavaScript Tutorial #06 Data Types
Variables in JavaScript are not directly associated with any data types. JavaScript variables can store all data types value like as string, number, object, symbol etc.
The JavaScript language provides 6 primitive data types:
- Undefined
- Null
- Number
- String
- Boolean
- Symbol
Undefined
A variable that has not assigned a value. And hold the value undefined. It is just like null.
Null
A variable has defined with null value. It is like as undefined. It's store nothing.
Number
There is only one number type. There is no specific type for integers. Number can written with or without decimal point. It is able to represent floating-point numbers, the number type has three symbolic values: +Infinity, -Infinity, and NaN (not-a-number).
String
A string in JavaScript is a sequence of characters. In JavaScript, strings can be created directly by placing the series of characters between double (") or single (') quotes.
Boolean
It is logical a entity. A variable can have two values true
or false
.
Symbol
New in ECMAScript6. A Symbol is a unique and immutable identifier.
Object
In JavaScript, objects can be seen as a collection of properties. JavaScript objects are written with curly braces {}. The properties are stored in key value pairs. Property values can be values of any type, including other objects.
The typeof Operator
In JavaScript using typeof
operator to find the type of a JavaScript variable.