Java Script


JavaScript Tutorial


Admission Enquiry Form

Data Types in JavaScript

The type of value a variable strores in JavaScript is known as data type of that variable. JavaScript variables can store numbers or integers, strings, float, boolean and more. In JavaScript var keyword is used at the place of data type. var represents generic and variable declared using var keyword can store any type of data.

Example:


<script>
var str="Compuhelp" //String
var age=20; //Number or Integer
var length=16.34 //float
var bool=true; //boolean
</script>


 

Note:

var str="100"; // this "100" will be treated as string because it is placed in double quotes.

var str1="45.35" // this decimal value will also be treated as string.