{

# Javascript Learn Infinity Property Basics|number ifFinite method example

## Infinity Property in javascript

`Infinity` is a property of a Global Object, that specifies positive values of numeric data. The default value of `infinity` is Number.POSITIVE_INFINITY:

It represents the Mathematical Infinity value. In mathematical calculations, Any value divided by Zero is returned by infinity

### Syntax

``````Infinity
``````

### Javascript Infinity Example Usage

The number value is divided by Zero. and the Infinity value is always the largest value of any numeric value When you are adding/multiply any value with infinity will get Infinity

``````console.log(123/0) // Infinity
console.log(Infinity) // Infinity
console.log(Infinity - Infinity) // NaN
console.log(Infinity+Infinity) // Infinity
console.log(Infinity*Infinity) // Infinity
``````

Infinity value is represented in Positive and Negative Number.POSITIVE_INFINITY - Represents Positive infinite values - Infinity Number.NEGATIVE_INFINITY - Represents Negative Infinite value - -Infinity Infinity property usages

1. This will be used to check arithmetic operations result in comparison with Infinity.
2. This will also be used to store the infinite value of any calculations
3. Checking infinite value for Division

### Check and Compare Infinity value in javascript

Infinity can be used as a variable in conditional if the expression

``````var value = 45;
if (45< Infinity>)
console.log('Value is less than the infinite value')
``````

output is

``````Value is less than the infinite value
``````

### Number isFinite() method

`isFinite()` is defined in `Number` Object. isFinite() method checks value for a finite number, return true for a finite number, false for an infinite number.

Syntax:

``````Number.isFinite(numericvalule)
``````

Example Following is an To check Given number is finite or infinite using isFinite() method.

``````console.log(Number.isFinite(123)) // true
console.log(Number.isFinite(Infinity)) //false
console.log(Number.isFinite(null)) //false
console.log(Number.isFinite(NaN)) //false
console.log(Number.isFinite(-Infinity)) //false
console.log(Number.isFinite(undefined)) //false
``````
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.

Related posts