JavaScript-Number

JavaScript-Number

In java script all numbers are represented in floating point values, not in integer, float or hexadecimal. Javascript use 64 bit (IEEE 754), to represent a floating point number, but in case of index of Array and bitwise operator javascript use 32 bit floating point number.

Number type variable deceleration

var num = 10,
var count = 20,

In Javascript we can represent number in hex notation

var hex = 0x887
var count = 0x55,

In Javascript we can represent number in exponential notation

var exp = .555E-11,
var count = .345E-5,

In Javascript some special type of number Infinity, -Infinity, because of that divide by zero is allowed in Javascript.

var inf = 10/0
var inf2 = -50/0,
var inf3 = 0/0   //output  **NaN** (Not a Number)

Object.prototype.toString.call(inf)   //output "[object Number]"

Javascript number methods

isFinite() : for every finite output it return true. and false for NaN, Infinite, -Infinite.

isFinite(0/0)  // output false
isFinite(10/0)  // output false
isFinite(-10/0)  // output false
isFinite(10/5)  // output true

Related Article