Data Types - Part 2

Notes:

JavaScript Types of Data types:

JavaScript Data types can be divided into three types:

Primitive Data Types: number, string, Boolean
Special Data Types: undefined, null
Composite Data Types: object etc.

Primitive Data Types: Value Types
1. number: indicates both integer and real numbers
Integers: means whole numbers
Ex: 122, 2000, -400, etc
Real numbers: means float numbers, i.e. numbers containing floating point
Ex: 3.142, 9.8,-48.32 etc.

2. string: indicates sequence of characters enclosed in double quotations or single quotations
i.e. Textual data.
Note:
If a string begins with single quote then it has to end with single quote and
If a string begins with double quote then it has to end with double quote.
Ex:
“Hello World”
‘Hello JavaScript’
etc.

3. boolean: indicates logical or conditional result
Boolean data type has two values true and false value.
In JavaScript true indicates 1 and false indicates 0
Special Data Types: Default Values

1. undefined: indicates un-initialized.
It is the default value of un-initialized variable.
If we store undefined value in a variable its type will be set to undefined.

2. null: indicates the nothing.
If we store null in a variable its type is set to object.
Object type is also known as reference or pointer type,
A variable of type object points or refers to another memory location; if it should not point to any memory location then assign a value null.

Composite Data Types: Reference types or Object types
Instead of holding value they hold the address of another memory location.
Ex: Arrays, functions, RegExp, Date etc. are all example for Object types

Interview Questions: