Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

The Math.log10() Method

The Math.log10(x) method returns the logarithm of x to the base 10.

Example

Math.log10(10);    // returns 1

New Number Properties

ES6 introduced the following properties to the Number object:

  • EPSILON
  • MIN_SAFE_INTEGER
  • MAX_SAFE_INTEGER

EPSILON Example

let x = Number.EPSILON;

MIN_SAFE_INTEGER Example

let x = Number.MIN_SAFE_INTEGER;

MAX_SAFE_INTEGER Example

let x = Number.MAX_SAFE_INTEGER;

The Number.isInteger() Method

The Number.isInteger() method checks whether a given value is an integer.

Example

Number.isInteger(10);        // returns true
Number.isInteger(10.5);      // returns false

The Number.isSafeInteger() Method

A safe integer is an integer that can be precisely represented as a double-precision number.

The Number.isSafeInteger() method returns true if the given argument is a safe integer.

Example

Number.isSafeInteger(10);    // returns true
Number.isSafeInteger(12345678901234567890);  // returns false

Safe integers range from -(2^53 – 1) to +(2^53 – 1).

For example, 9007199254740991 is a safe integer, while 9007199254740992 is not.

New Global Methods

ES6 introduced two new global number methods:

  • isFinite()
  • isNaN()

The isFinite() Method

The global isFinite() method returns false if the argument is Infinity or NaN; otherwise, it returns true.

Example

isFinite(10/0);       // returns false
isFinite(10/1);       // returns true

The isNaN() Method

The global isNaN() method returns true if the argument is NaN; otherwise, it returns false.

Example

isNaN(“Hello”);       // returns true

Modules

Modules can be imported in two different ways:

Import from named exports

Import specific exports from the person.js file:

import { name, age } from “./person.js”;

Import from default exports

Import the default export from the message.js file:

import message from “./message.js”;