|
|
Numbers (Integer & Float)
|
Tutorials

Javascript

|
Topic |
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 Code:
<script language="javascript">
var a = 2;
var b = 3;
var c = a+b;
document.write(" addition - ");
document.write(c);
</script>
Result:
addition - 5
|
| A Note |
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script.
Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.
|
|
|
|