Types of Data in JavaScript
You deal with different types of information every day in programming languages we handle them by saying this is integer this is number this is float this is double this is string and symbols etc. Like your name is string, your age is int, your date of birth is date. In Programming languages we have to deal with them according to programming language so language can recognize them.
Suppose you have a variable number and you save in it 22 and you have another variable in which you save your name we cannot plus or sum them. Cause your name is string and that number is integer.
Numbers in JavaScript
In JavaScript we save numbers without calling int in start of variable name cause if we are saving any number without quotes in a variable then javaScript can recognize this is not a string. We do same for float and double numbers as well.
Variables in JavaScript
We write var in start of variables of javaScript and then we save string in it. Below are some examples of numbers, float, double, string.
[code lang=”js”]
<script type="text/javaScript">
var myName = "Ateeq Rafeeq"; //This is a string Variable.
num = 123; // This is a Number
float_num = 12.55; //this is a float number
double_num = 1230.12341234; //This is double num
</script>
[/code]
We cannot keep variable names words like float, double, var, int, new etc cause they are javaSCript keywords and javaScript need them for itself so we cannot name any variable like var float = 11;