- 1
Integers in javascript?
How to define integers in js for e.g. to add a particular no. to 1 or 2 ,etc.
3 Réponses
+ 2
Javascript is a dynamically typed language. That means that you, as a developer, don't have to use specific datatypes to declare a variable. Instead, all variables are created with 'var'.
That means it's possible to add a 1 like this:
var x = 3;
x = x + 1;
If you want to make sure that x stores an integer, there are numerous helpful methods (e.g. Number.isInteger()). You could also use HTML forms to make sure that only numbers can be typed.
+ 11
var num = 1
alert(num+1)
?
AFAIK, JavaScript numbers are always 64-bit floating point values.
0
Ty guys...