JavaScript Tutorial

adplus-dvertising
Data Types in JavaScript
Previous Home Next

JavaScript provides several data types to hold different types of values. There are Manely two types of datatype used in JavaScript.

  1. Primitive (value) data type
  2. Non-primitive (reference) data type

primitive data type is a data type that stores a single value, normally a literal of some sort, such as numbers and strings.

non primitive data type is a data type that can be used by reference ,it can be changed or access through member

JavaScript primitive data types

There are five types of primitive data types used in JavaScript. they are given below

Data Type Description
String represents sequence of characters e.g. "prasun"
Number represents numeric values e.g. 500
Boolean its represents boolean value either or true false
Undefined its represents undefined value
Null represents null (i.e. means) no value at all

Example:

<html>
<head>
<p>Example of primitive data types</p>

<script="script/text">
string ="prasant prasun"<br>
num="85"<br>
bool="true or false"<br>

</script>
<head>
<html> 

Output :

Example of primitive data types
string ="prasant prasun"
num="85"
bool="true or false"

JavaScript non-primitive data types

The non-primitive data types which is used in javascript they are given below

Data Type Description
Object its represents instance which can access through members
Array its represents a group of similar values
RegExp its represents regular expression
Previous Home Next