How to find the data type of a variable in JavaScript

{0 Comments}

To check the data type of variable you can use “typeof” operator present in JavaScript. By using this operator you can conform that whether the type of variable is a string, int, or a char etc. following is the syntax to use ‘typeof’ operator

 Javascript |  copy code |? 
1
var abc=3
2
alert(typeof abc) 

This will give result as ‘number’, and following are the values which it can detect. 

Value it can detect
“number”
“string”
“boolean”
“object”
null
 

Leave a Comment

Your email address will not be published.