DEV Community

Cover image for What Are JavaScript Data Types?
Okanu Gracious
Okanu Gracious

Posted on

What Are JavaScript Data Types?

Data Types specify the kind of data stored and manipulated in a program.

Data Types can be categorized into six parts which isn’t divided into three main categories.....

1. Primitive:
<>Number
<>String
<>Boolean

2. Compound:
<>Array
<>Object
<>Function

3. Undefined:
<>Undefined

The two most common categories are know to be different from each other because primitive data Types can only contain one value simultaneously while the compound data Types can contain more values.
Let’s explain them accordingly...

<>String Data Type<>:
This data type deals with textual values and characters which are created with the double or single quotation mark on the keyboard. Example...

var a = “hi there”;
var b = “hello there”;
Enter fullscreen mode Exit fullscreen mode

<>Number Data Type<>:
This data type deals with positive and negative numbers without or with decimal numbers and places written using exponential quotations.

Example....

var c = 24;
var d = 23.7;
Enter fullscreen mode Exit fullscreen mode

Note: When writing codes for Number Data Types, strings are not supported in other To bring a desired outcome.

<>Boolean Data Type<>:
The Boolean Data Type can only contain two values: TRUE or FALSE.
It is usually used to show values like Yes(true) or No(false). For example....

var Show = true;
var IsShow = false;
Enter fullscreen mode Exit fullscreen mode

<>Undefined Data Type<>:
This data type is can be used to assign a single value: The Undefined Special Value.
This data type is effective when you declare a variable without a value.
For example....

var d;
var e = “Okanu Gracious”;

alert(d) // Output: Undefined
alert(e) // Output: Okanu Gracious

Enter fullscreen mode Exit fullscreen mode

<>Object Data Type<>:
The object Data type is a very complex data type in JavaScript which has one sole aim. The aim of the object data type is to store large collections of data.
An example of Object Data Type are....

var WebDev = {
Frontend : “HTML and CSS”
Backend : “MySQL and Python”
}
Enter fullscreen mode Exit fullscreen mode

<>Array Data Type<>:
An array data type is a type of data type where a programmer inputs different data values in a single variable. An example of Array data type includes....

var Frontend = [“HTML”, “CSS”, “JavaScript”, “ReactJS”, “Vue”]

alert(Frontend[0]); // Output: HTMl
Enter fullscreen mode Exit fullscreen mode

<>Function Data Type<>:
This is data type which executes a block of codes. Functions can be used anywhere, it can be stored in an array, objects, variables, anywhere.
An example of Function Data Type are...

function Myfunction(){
console.log(“hello”)
}
Enter fullscreen mode Exit fullscreen mode

Thank you for reading!
Do follow me on Twitter @okanugracious

Latest comments (1)

Collapse
 
graciousdev profile image
Okanu Gracious

Thank you sir.
I’m still a beginner