Javascript Numbers

Numbers or integers are whole numbers or fractional numbers. Numbers can be added, subtracted, multiplied and divided, thus perform all arithmetic operations.


 var a=3;    	    // number; 
 var b=3.6;         // number with decimal; 
 var c=0xa;         // number in hexadecimal 
 var d=010;         // number in octal
 var e=0b100;       // number in binary
 var f=Infinity;    // number more than 10308 
 


Methods of Numbers

MethoduseExample
toString()convert number to string.var x=6;
x.toString()="6";
toLocalString()convert number to local string.var x=6;
x.toLocalString()="6";
toExponential()convert decimal to exponential notation.var x=6;
x.toExponential()="6e+0";
toPrecision(1)convert number to Precise .var x=1.23456;
x.toPrecision(1)="1";
toPrecision(2)convert decimal to exponential notation.var x=1.23456;
x.toPrecision(2)="1.2";
toPrecision(3)convert decimal to exponential notation.var x=1.23456;
x.toPrecision(3)="1.23";

"+" operator and "concat()" method, both concat strings in javascript.