- 1

Integers in javascript?

How to define integers in js for e.g. to add a particular no. to 1 or 2 ,etc.

29th Dec 2017, 7:22 AM
R I S H A B H
R I S H A B H - avatar
3 odpowiedzi
+ 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.
29th Dec 2017, 7:36 AM
Milambis
Milambis - avatar
+ 11
var num = 1 alert(num+1) ? AFAIK, JavaScript numbers are always 64-bit floating point values.
29th Dec 2017, 7:30 AM
Hatsy Rei
Hatsy Rei - avatar
0
Ty guys...
29th Dec 2017, 7:37 AM
R I S H A B H
R I S H A B H - avatar