0% found this document useful (0 votes)
738 views

Data Types of JavaScript

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
738 views

Data Types of JavaScript

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Types

A data type is a classification of the type of data that a variable or an object can
hold. Data type is an important factor in all computer programming languages,
including Visual Basic, C#, C/C++ and JavaScript. JavaScript supports different
data types.
DATA TYPE

PRIMITIVE DATA TYPE COMPOSITE

Object
Array
Numeric String Boolean Function

Integer Floating point


Primitive Data Types
These types of data are called building blocks of a program. A single literal value
is assigned of type number, string characters. JavaScript supports three basic
data types:
1. Numeric: Numeric type has two type viz. Integer and floating point. Integer is
a whole number such as 145, -9 etc. Integer can hold both positive and negative
values.
Floating point are values with decimal value or fractional value. For example 12.3,
1.5e-2 are the floating point examples. numbers in JavaScript are double
precision 64-bit format.
2. String: Strings are collection of characters which are enclosed with either
Single(‘ ‘) or double quotes(“ “). A starting and ending quotes of string value
must be matched. Single quotes can hide the double quotes or double quotes
can hide the single quotes. For example:
"This is a beautiful Scene"
' This is a beautiful Scene '
" This is a beautiful ‘Scene’ "
' This is a beautiful “Scene "'
3. Boolean: This type of data contains only two value i.e. true or false or 0 or 1.
When these values are compared then true value is taken as 1 and false
value is taken as 0. A numeric comparison and equality operator is used for
comparison.
Composite Data Types
These types of data type are complex in nature which consist more than one
component. Object, arrays and functions are the example of composite data type.
Object contains properties and methods; array contains a sequential list of
elements and functions contains a collection of statements.
Null and Undefined Values
A null keyword represents “no value”. It is not empty string or zero, Null value
is used to initialized the object to clear the value of a variable and memory
assigned to object becomes the free.
When a variable is declared without assigning value then it contains the
‘undefined’ value which may cause the runtime error. Variables compared
with these values can be compared with identity operator.

You might also like