Variable Types - Numbers
- Forums
- Javascipt
- Variable Types - Numbers
This Page Contains information about Variable Types - Numbers By Webune in category Javascipt with 0 Replies. [2174], Last Updated: Mon Jun 24, 2024
Webune
Fri May 23, 2008
0 Comments
387 Visits
numbers are just that, numbers. javascript does not require numbers to be declared as intergers, floating-point decimal numbers, or any other number type. instead, any numbers is seen as just another number. whether it is 7, -2, 3.43 or anything else. the number will remain the same type unless you perform a calculation to change the type. for example, if you suse an interger in a variable, it wont't suddently have decimals places unless you perform a calculation of some sort ot chane it or divinging unevely for example
as you can know, you define a number vairalble ny using the keyword var:
var examplevariable = number;
here are some exaples:
var paycheck = 1200;
var phonebill = 29.99;
var savings = 0;
var sparetime = -24.5;
if you need to use a particular long number, javascript has exponential notation. to denote the exponent use a letter e right after the base number and before the exponent. for examplke, to create a variable named bignumber and assign it a value of 4.52 x 10^5(452000) put the letter e in place of everything between the exponent to represent the phrase time 10 to the power of
example
var bignumber = 4.5e5