JavaScript Datatypes | Types of Datatypes | Learn JS Online

JavaScript Datatypes

0 1024

Every programming language contains certain set of data types. Identical to other languages, JavaScript also enclose datatypes to hold different types of values. There is no requirement of specifying type of variables like other languages because JavaScript is a dynamic scripting language, where program is dynamically identified by JS engine.

In JavaScript,
# No type cast (JS is loosely type language)
# No need to specify types of variable. (Dynamic Script Language)

There required using var to specify data types, it can hold any type of variables like number, String.

For Example:
Var height= 34; // number
Var volume=35; // number
Var name="arie" // string

Data Types are categorized into two types:
1) Primitive
2) Non primitive

1) Primitive Datatypes:
Immutable datatypes are referred as primitive datatypes because once these data values gets creates there is no another method to modify it.
These are fundamental types found in JavaScript such as String, Boolean, Undefined, number and Null

A Boolean data type characterizes only two values i.e. true, or false.

var booleon7 = true;
var booleon8 = false;

JavaScript contains only one number type for representing negative or positive numbers. There is no requirement of a distinct designation for floating-points and integers, thus number can be written with both decimals as well as without decimal.

Suppose number1 = 65;
Suppose number2 = 93.00;

Undefined datatype
This type of datatype contains one undefined value i.e. a value is not assigned to a variable
Var k;
Var h="welcome in codingtag";

A variable found to have a null value i.e. an empty variable.

var z = null;

This type of data type is used for representing all textual based data such as sequences of characters. One can create a string in JavaScript through single or double quotes

var f = 'codingtag!';
var g = "codingtag!";

2) Non-primitive Datatypes
The mutable datatypes are referred as Non-primitive. There are three non-primitive datatypes in JavaScript i.e. Object, Array and RegExp


Leave a Reply

    Waiting for your comments