Numbers (Integer & Float)
What are the different variable type of numbers in javascript?
How can I assign integer/float values in java script?
Explanation
Number: Numbers can be used in two different types in javascript. They are integer and float.
Integer- E.g: 2
For a variable to be of int type just assign number with out any quotes.
i.e if
var a = 2;
var b = 2;
then a+b gives 4.
Float- E.g: 2.12
For a variable to be of float type just assign fractional number with out any quotes.
i.e if
var a = 2.12;
var b = 2.12;
then a+b gives 4.24
Important:
Never forget that number types should not have any quotes.
Example:
<script language="javascript">
var a = 2;
var b = 3;
var c = a+b;
document.write(" addition - ");
document.write(c);
</script>
Result:
addition - 5