All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Javascript Data Types

Data Types is a very important part of any programming language.It decides the variable type like the variable is number, string, array, boolean etc.



Numbers

In this datatype the variable is store any numeric value. All numbers in JavaScript are represented as floating-point values.


var a = 84983;

var b = 6783.343;

var c = 0.232;

var d = 4 x 102;


String

In this datatype the variable is store any character or group of character and the values is stored within quotes.


var a = " A ";

var b = " Apple ";

var c = " Hello JavaScript ";



Boolean

In this datatype the variable is store eighter true or false.


var a = true;

var b = false;



Array

In this datatype the variable is store one or more values all the values seperated with commas with quotes and arrays are written within square brackets.


var name = [ " Rahul " ];

var fruits = [ " Apple ", " Banana ", " Orange " ];

var info = [ " 21 ", " 23.50 ", " Physics " ];



Get variable type usinf typeof operator

You can get any variable type using typeof operator


var a = " Hello" ;
typeof a // it returns string

var b = 335 ;
typeof b // it returns number


var c = true ;
typeof c // it returns boolean


var d = [ " PHP ", " CSS ", " HTML " ] ;
typeof d // it returns array
❮ PreviousNext ❯