Skip to Content
JavaScript: The Definitive Guide, 6th Edition
book

JavaScript: The Definitive Guide, 6th Edition

by David Flanagan
May 2011
Intermediate to advanced
1093 pages
40h 54m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, 6th Edition

Name

Number — support for numbers

Inherits from

Object → Number

Constructor

new Number(value)
Number(value)

Arguments

value

The numeric value of the Number object being created or a value to be converted to a number.

Returns

When Number() is used with the new operator as a constructor, it returns a newly constructed Number object. When Number() is invoked as a function without the new operator, it converts its argument to a primitive numeric value and returns that value (or NaN if the conversion failed).

Constants

Number.MAX_VALUE

The largest representable number.

Number.MIN_VALUE

The smallest representable number.

Number.NaN

Not-a-number value.

Number.NEGATIVE_INFINITY

Negative infinite value; returned on overflow.

Number.POSITIVE_INFINITY

Infinite value; returned on overflow.

Methods

toString()

Converts a number to a string using a specified radix (base).

toLocaleString()

Converts a number to a string using local number-formatting conventions.

toFixed()

Converts a number to a string that contains a specified number of digits after the decimal place.

toExponential()

Converts a number to a string using exponential notation with the specified number of digits after the decimal place.

toPrecision()

Converts a number to a string using the specified number of significant digits. Uses exponential or fixed-point notation depending on the size of the number and the number of significant digits specified.

valueOf()

Returns the primitive numeric value of a Number object.

Description

Numbers are a basic, primitive datatype ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: The Definitive Guide, 5th Edition

JavaScript: The Definitive Guide, 5th Edition

David Flanagan

Publisher Resources

ISBN: 9781449393854Errata PageSupplemental Content