How to find the data type of a variable in JavaScript


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 |? 
var abc=3
alert(typeof abc) 

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

Value it can detect

Leave a Comment

Your email address will not be published.