totn JavaScript

JavaScript: Number.EPSILON property

This JavaScript tutorial explains how to use the Number property called EPSILON with syntax and examples.

Description

In JavaScript, EPSILON is a static property of the Number object that is used to return the smallest positive number approaching zero (ie: a positive infinitesimal quantity). Because EPSILON is a property of the Number object, it must be invoked through the object called Number.

Syntax

In JavaScript, the syntax for the EPSILON property is:

Number.EPSILON;

Parameters or Arguments

There are no parameters or arguments for the EPSILON property.

Returns

The EPSILON property returns an approximate value of 2.220446049250313e-16.

Note

  • The EPSILON property is a property of the Number object and not a number function. However, we have included the EPSILON property within our JS Number Methods section because you will most likely use this property in conjunction with the Number methods found in this section.

Example

Let's take a look at an example of how to use the EPSILON property in JavaScript.

For example:

console.log(Number.EPSILON);

In this example, we have invoked the EPSILON property using the Number class.

We have written the output of the EPSILON property to the web browser console log, for demonstration purposes, to show what the EPSILON property returns.

The following will be output to the web browser console log:

2.220446049250313e-16

In this example, the EPSILON property returned a value of 2.220446049250313e-16 which represents the smallest positive number in JavaScript that is approaching zero.