Posts Data Types of JavaScript
Post
Cancel

Data Types of JavaScript

Hello there welcome to my Javascript tutorial, today we are talking about Data types of javascript.There are 5 basic data types in js(Javascript). Those are numbers, booleans, objects, arrays, strings .

Variables

Variables of js are same like variables in math.They can change.

1
let age  = 20 ;

All variables should declared using the key word let like let a="rohit";.First the keyword var is used for declaring the variables. All data types are declared from let keyword.

Data Types

Numbers

Numbers can be decimal or non decimal.You can do operations on them using there variable.

Table contaning oparators of javascript

OperatorDescription
+Addition
-Subtraction
*Multiplication
**Exponentiation
/Division
%Modulus (Remainder)
++Increment
--Decrement

Strings

Strings can be defined in double cotes ("") or single(''). If you try for for:

1
2
3
let a = 20;
let b = 'he'
let c = a + b;

Then the answer will be 20he.What? Yes thats right Js engin treats the variable a as a string and concatnate them.

Booleans

Booleans have only two values true and false.Only two no more. if you think like a variable a = 20 and b = 20 if you write c = a == b then the value would be true a boolean value.

This post is licensed under CC BY 4.0 by the author.