?
u
m
/
p
1-9
The Number
extends
clause of a class definition. Subclass super
call to the Number This function performs the following steps when called:
The Number
The value of Number.EPSILON
is the
This property has the attributes { [[Writable]]:
This function performs the following steps when called:
This function performs the following steps when called:
This function performs the following steps when called:
This function differs from the global isNaN function (
An
This function performs the following steps when called:
Due to rounding behaviour necessitated by precision limitations of Number.MAX_SAFE_INTEGER
is shared with at least one other 9007199254740992
and 9007199254740993
evaluate to the Number value
The value of Number.MAX_SAFE_INTEGER
is
This property has the attributes { [[Writable]]:
The value of Number.MAX_VALUE
is the largest positive
This property has the attributes { [[Writable]]:
Due to rounding behaviour necessitated by precision limitations of Number.MIN_SAFE_INTEGER
is shared with at least one other -9007199254740992
and -9007199254740993
evaluate to the Number value
The value of Number.MIN_SAFE_INTEGER
is
This property has the attributes { [[Writable]]:
The value of Number.MIN_VALUE
is the smallest positive value of the
In the Number.MIN_VALUE
must be the smallest non-zero positive value that can actually be represented by the implementation.
This property has the attributes { [[Writable]]:
The value of Number.NaN
is
This property has the attributes { [[Writable]]:
The value of Number.NEGATIVE_INFINITY
is
This property has the attributes { [[Writable]]:
The initial value of the
The initial value of the
The value of Number.POSITIVE_INFINITY
is
This property has the attributes { [[Writable]]:
The initial value of Number.prototype
is the
This property has the attributes { [[Writable]]:
The Number prototype object:
Unless explicitly stated otherwise, the methods of the Number prototype object defined below are not generic and the
The phrase “this Number value” within the specification of a method refers to the result returned by calling the abstract operation
The initial value of Number.prototype.constructor
is
This method returns a String containing this Number value represented in decimal exponential notation with one digit before the significand's decimal point and fractionDigits digits after the significand's decimal point. If fractionDigits is
It performs the following steps when called:
For implementations that provide more accurate conversions than required by the rules above, it is recommended that the following alternative version of step
This method returns a String containing this Number value represented in decimal fixed-point notation with fractionDigits digits after the decimal point. If fractionDigits is
It performs the following steps when called:
The output of toFixed
may be more precise than toString
for some values because toString only prints enough significant digits to distinguish the number from adjacent Number values. For example,
(1000000000000000128).toString()
returns
(1000000000000000128).toFixed(0)
returns
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method produces a String value that represents this Number value formatted according to the conventions of the toString
.
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method returns a String containing this Number value represented either in decimal exponential notation with one digit before the significand's decimal point and
It performs the following steps when called:
The optional radix should be an
This method performs the following steps when called:
This method is not generic; it throws a
The
The abstract operation ThisNumberValue takes argument value (an
Number instances are
The BigInt
new
operator or to be subclassed. It may be used as the value of an extends
clause of a class definition but a super
call to the BigInt This function performs the following steps when called:
The abstract operation NumberToBigInt takes argument number (a Number) and returns either a
The BigInt
This function performs the following steps when called:
This function performs the following steps when called:
The initial value of BigInt.prototype
is the
This property has the attributes { [[Writable]]:
The BigInt prototype object:
The phrase “this BigInt value” within the specification of a method refers to the result returned by calling the abstract operation
The initial value of BigInt.prototype.constructor
is
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method produces a String value that represents this BigInt value formatted according to the conventions of the toString
.
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
The optional radix should be an
This method performs the following steps when called:
This method is not generic; it throws a
The abstract operation ThisBigIntValue takes argument value (an
The initial value of the
This property has the attributes { [[Writable]]:
BigInt instances are
The Math object:
new
operator.In this specification, the phrase “the
The
This property has the attributes { [[Writable]]:
The
This property has the attributes { [[Writable]]:
The
This property has the attributes { [[Writable]]:
The
This property has the attributes { [[Writable]]:
The value of Math.LOG10E
is approximately the reciprocal of the value of Math.LN10
.
The
This property has the attributes { [[Writable]]:
The value of Math.LOG2E
is approximately the reciprocal of the value of Math.LN2
.
The
This property has the attributes { [[Writable]]:
The
This property has the attributes { [[Writable]]:
The value of Math.SQRT1_2
is approximately the reciprocal of the value of Math.SQRT2
.
The
This property has the attributes { [[Writable]]:
The initial value of the
This property has the attributes { [[Writable]]:
The behaviour of the functions acos
, acosh
, asin
, asinh
, atan
, atanh
, atan2
, cbrt
, cos
, cosh
, exp
, expm1
, hypot
, log
, log1p
, log2
, log10
, pow
, random
, sin
, sinh
, tan
, and tanh
is not precisely specified here except to require specific results for certain argument values that represent boundary cases of interest. For other argument values, these functions are intended to compute approximations to the results of familiar mathematical functions, but some latitude is allowed in the choice of approximation algorithms. The general intent is that an implementer should be able to use the same mathematical library for ECMAScript on a given hardware platform that is available to C programmers on that platform.
Although the choice of algorithms is left to the implementation, it is recommended (but not specified by this standard) that implementations use the approximation algorithms for fdlibm
, the freely distributable mathematical library from Sun Microsystems (http://www.netlib.org/fdlibm).
This function returns the absolute value of x; the result has the same magnitude as x but has positive sign.
It performs the following steps when called:
This function returns the inverse cosine of x. The result is expressed in radians and is in the
It performs the following steps when called:
This function returns the inverse hyperbolic cosine of x.
It performs the following steps when called:
This function returns the inverse sine of x. The result is expressed in radians and is in the
It performs the following steps when called:
This function returns the inverse hyperbolic sine of x.
It performs the following steps when called:
This function returns the inverse tangent of x. The result is expressed in radians and is in the
It performs the following steps when called:
This function returns the inverse hyperbolic tangent of x.
It performs the following steps when called:
This function returns the inverse tangent of the quotient
It performs the following steps when called:
This function returns the cube root of x.
It performs the following steps when called:
This function returns the smallest (closest to -∞)
It performs the following steps when called:
The value of Math.ceil(x)
is the same as the value of -Math.floor(-x)
.
This function performs the following steps when called:
If n is either
This function returns the cosine of x. The argument is expressed in radians.
It performs the following steps when called:
This function returns the hyperbolic cosine of x.
It performs the following steps when called:
The value of Math.cosh(x)
is the same as the value of (Math.exp(x) + Math.exp(-x)) / 2
.
This function returns the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
It performs the following steps when called:
This function returns the result of subtracting 1 from the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms). The result is computed in a way that is accurate even when the value of x is close to 0.
It performs the following steps when called:
This function returns the greatest (closest to +∞)
It performs the following steps when called:
The value of Math.floor(x)
is the same as the value of -Math.ceil(-x)
.
This function performs the following steps when called:
Given zero or more arguments, this function returns the square root of the sum of squares of its arguments.
It performs the following steps when called:
The
Implementations should take care to avoid the loss of precision from overflows and underflows that are prone to occur in naive implementations when this function is called with two or more arguments.
This function performs the following steps when called:
This function returns the natural logarithm of x.
It performs the following steps when called:
This function returns the natural logarithm of 1 + x. The result is computed in a way that is accurate even when the value of x is close to zero.
It performs the following steps when called:
This function returns the base 10 logarithm of x.
It performs the following steps when called:
This function returns the base 2 logarithm of x.
It performs the following steps when called:
Given zero or more arguments, this function calls
It performs the following steps when called:
The comparison of values to determine the largest value is done using the
The
Given zero or more arguments, this function calls
It performs the following steps when called:
The comparison of values to determine the largest value is done using the
The
This function performs the following steps when called:
This function returns a Number value with positive sign, greater than or equal to
Each Math.random
function created for distinct
This function returns the Number value that is closest to x and is integral. If two
It performs the following steps when called:
Math.round(3.5)
returns 4, but Math.round(-3.5)
returns -3.
The value of Math.round(x)
is not always the same as the value of Math.floor(x + 0.5)
. When x
is x
is less than Math.round(x)
returns Math.floor(x + 0.5)
returns Math.round(x)
may also differ from the value of Math.floor(x + 0.5)
because of internal rounding when computing x + 0.5
.
This function returns the sign of x, indicating whether x is positive, negative, or zero.
It performs the following steps when called:
This function returns the sine of x. The argument is expressed in radians.
It performs the following steps when called:
This function returns the hyperbolic sine of x.
It performs the following steps when called:
The value of Math.sinh(x)
is the same as the value of (Math.exp(x) - Math.exp(-x)) / 2
.
This function returns the square root of x.
It performs the following steps when called:
This function returns the tangent of x. The argument is expressed in radians.
It performs the following steps when called:
This function returns the hyperbolic tangent of x.
It performs the following steps when called:
The value of Math.tanh(x)
is the same as the value of (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x))
.
This function returns the integral part of the number x, removing any fractional digits. If x is already integral, the result is x.
It performs the following steps when called:
The following
Time measurement in ECMAScript is analogous to time measurement in POSIX, in particular sharing definition in terms of the proleptic Gregorian calendar, an epoch of midnight at the beginning of 1 January 1970 UTC, and an accounting of every day as comprising exactly 86,400 seconds (each of which is 1000 milliseconds long).
An ECMAScript time value
Time values do not account for UTC leap seconds—there are no time values representing instants within positive leap seconds, and there are time values representing instants removed from the UTC timeline by negative leap seconds. However, the definition of time values nonetheless yields piecewise alignment with UTC, with discontinuities only at leap second boundaries and zero difference outside of leap seconds.
A Number can exactly represent all
The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the time value
In the proleptic Gregorian calendar, leap years are precisely those which are both divisible by 4 and either divisible by 400 or not divisible by 100.
The 400 year cycle of the proleptic Gregorian calendar contains 97 leap years. This yields an average of 365.2425 days per year, which is 31,556,952,000 milliseconds. Therefore, the maximum range a Number could represent exactly with millisecond precision is approximately -285,426 to 285,426 years relative to 1970. The smaller range supported by a time value as specified in this section is approximately -273,790 to 273,790 years relative to 1970.
These constants are referenced by algorithms in the following sections.
The abstract operation Day takes argument t (a
The abstract operation TimeWithinDay takes argument t (a
The abstract operation DaysInYear takes argument y (an
The abstract operation DayFromYear takes argument y (an
The abstract operation TimeFromYear takes argument y (an
The abstract operation YearFromTime takes argument t (a
The abstract operation DayWithinYear takes argument t (a
The abstract operation InLeapYear takes argument t (a
The abstract operation MonthFromTime takes argument t (a
The abstract operation DateFromTime takes argument t (a
The abstract operation WeekDay takes argument t (a
The abstract operation HourFromTime takes argument t (a
The abstract operation MinFromTime takes argument t (a
The abstract operation SecFromTime takes argument t (a
The abstract operation msFromTime takes argument t (a
The abstract operation GetUTCEpochNanoseconds takes arguments year (an
Time zones in ECMAScript are represented by time zone identifiers, which are Strings composed entirely of code units in the
A primary time zone identifier is the preferred identifier for an available named time zone. A non-primary time zone identifier is an identifier for an available named time zone that is not a primary time zone identifier. An available named time zone identifier is either a primary time zone identifier or a non-primary time zone identifier. Each available named time zone identifier is associated with exactly one available named time zone. Each available named time zone is associated with exactly one primary time zone identifier and zero or more non-primary time zone identifiers.
ECMAScript implementations must support an available named time zone with the identifier
Implementations that follow the requirements for time zones as described in the ECMA-402 Internationalization API specification are called time zone aware.
Time zone aware implementations must support available named time zones corresponding to the Zone and Link names of the IANA Time Zone Database, and only such names.
In time zone aware implementations, a primary time zone identifier is a Zone name, and a non-primary time zone identifier is a Link name, respectively, in the IANA Time Zone Database except as specifically overridden by
The
When the input represents a local time occurring more than once because of a negative time zone transition (e.g. when daylight saving time ends or the time zone offset is decreased due to a time zone rule change), the returned
The default implementation of GetNamedTimeZoneEpochNanoseconds, to be used for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:
It is required for
1:30 AM on 5 November 2017 in America/New_York is repeated twice, so GetNamedTimeZoneEpochNanoseconds(
2:30 AM on 12 March 2017 in America/New_York does not exist, so GetNamedTimeZoneEpochNanoseconds(
The
The returned
The default implementation of GetNamedTimeZoneOffsetNanoseconds, to be used for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:
Time zone offset values may be positive or negative.
A Time Zone Identifier Record is a
Time Zone Identifier Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[Identifier]] | a String | An |
[[PrimaryIdentifier]] | a String | The |
If [[Identifier]] is a
The
The
To ensure the level of functionality that implementations commonly provide in the methods of the Date object, it is recommended that SystemTimeZoneIdentifier return an IANA time zone name corresponding to the
For example, if the
The abstract operation LocalTime takes argument t (a
If political rules for the local time t are not available within the implementation, the result is t because
It is required for
Two different input
The abstract operation UTC takes argument t (a Number) and returns a
Input t is nominally a
If political rules for the local time t are not available within the implementation, the result is t because
It is required for
1:30 AM on 5 November 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05.
In UTC(
2:30 AM on 12 March 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05 (equivalent to 3:30 AM UTC-04).
In UTC(
The abstract operation MakeTime takes arguments hour (a Number), min (a Number), sec (a Number), and ms (a Number) and returns a Number. It calculates a number of milliseconds. It performs the following steps when called:
The arithmetic in MakeTime is floating-point arithmetic, which is not associative, so the operations must be performed in the correct order.
The abstract operation MakeDay takes arguments year (a Number), month (a Number), and date (a Number) and returns a Number. It calculates a number of days. It performs the following steps when called:
The abstract operation MakeDate takes arguments day (a Number) and time (a Number) and returns a Number. It calculates a number of milliseconds. It performs the following steps when called:
The abstract operation MakeFullYear takes argument year (a Number) and returns an
The abstract operation TimeClip takes argument time (a Number) and returns a Number. It calculates a number of milliseconds. It performs the following steps when called:
ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 calendar date extended format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ
Where the elements are as follows:
YYYY
|
is the year in the proleptic Gregorian calendar as four decimal digits from 0000 to 9999, or as an |
-
|
|
MM
|
is the month of the year as two decimal digits from 01 (January) to 12 (December). |
DD
|
is the day of the month as two decimal digits from 01 to 31. |
T
|
|
HH
|
is the number of complete hours that have passed since midnight as two decimal digits from 00 to 24. |
:
|
|
mm
|
is the number of complete minutes since the start of the hour as two decimal digits from 00 to 59. |
ss
|
is the number of complete seconds since the start of the minute as two decimal digits from 00 to 59. |
.
|
|
sss
|
is the number of complete milliseconds since the start of the second as three decimal digits. |
Z
|
is the UTC offset representation specified as HH:mm (a subset of the |
This format includes date-only forms:
YYYY YYYY-MM YYYY-MM-DD
It also includes “date-time” forms that consist of one of the above date-only forms immediately followed by one of the following time forms with an optional UTC offset representation appended:
THH:mm THH:mm:ss THH:mm:ss.sss
A string containing out-of-bounds or nonconforming elements is not a valid instance of this format.
As every day both starts and ends with midnight, the two notations 00:00
and 24:00
are available to distinguish the two midnights that can be associated with one date. This means that the following two notations refer to exactly the same point in time: 1995-02-04T24:00
and 1995-02-05T00:00
. This interpretation of the latter form as "end of a calendar day" is consistent with ISO 8601, even though that specification reserves it for describing time intervals and does not permit it within representations of single points in time.
There exists no international standard that specifies abbreviations for civil time zones like CET, EST, etc. and sometimes the same abbreviation is even used for two very different time zones. For this reason, both ISO 8601 and this format specify numeric representations of time zone offsets.
Covering the full Date.parse
Examples of date-
-271821-04-20T00:00:00Z | 271822 B.C. |
-000001-01-01T00:00:00Z | 2 B.C. |
+000000-01-01T00:00:00Z | 1 B.C. |
+000001-01-01T00:00:00Z | 1 A.D. |
+001970-01-01T00:00:00Z | 1970 A.D. |
+002009-12-15T00:00:00Z | 2009 A.D. |
+275760-09-13T00:00:00Z | 275760 A.D. |
ECMAScript defines a string interchange format for UTC offsets, derived from ISO 8601. The format is described by the following grammar.
The abstract operation IsTimeZoneOffsetString takes argument offsetString (a String) and returns a Boolean. The return value indicates whether offsetString conforms to the grammar given by
The abstract operation ParseTimeZoneOffsetString takes argument offsetString (a String) and returns an
The Date
extends
clause of a class definition. Subclass super
call to the Date This function performs the following steps when called:
parse
method (The Date
This function returns the
This function applies the
If the String conforms to the MM
or DD
elements are absent, HH
, mm
, or ss
elements are absent, sss
element is absent,
If x
is any Date whose milliseconds amount is zero within a particular implementation of ECMAScript, then all of the following expressions should produce the same numeric value in that implementation, if all the properties referenced have their initial values:
x.valueOf()
Date.parse(x.toString())
Date.parse(x.toUTCString())
Date.parse(x.toISOString())
However, the expression
Date.parse(x.toLocaleString())
is not required to produce the same Number value as the preceding three expressions and, in general, the value produced by this function is toString
or toUTCString
method.
The initial value of Date.prototype
is the
This property has the attributes { [[Writable]]:
This function performs the following steps when called:
The
This function differs from the Date
The Date prototype object:
Unless explicitly defined otherwise, the methods of the Date prototype object defined below are not generic and the
The initial value of Date.prototype.constructor
is
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
The
If month is not present, this method behaves as if month was present with the value getMonth()
. If date is not present, it behaves as if date was present with the value getDate()
.
This method performs the following steps when called:
The
If min is not present, this method behaves as if min was present with the value getMinutes()
. If sec is not present, it behaves as if sec was present with the value getSeconds()
. If ms is not present, it behaves as if ms was present with the value getMilliseconds()
.
This method performs the following steps when called:
This method performs the following steps when called:
The
If sec is not present, this method behaves as if sec was present with the value getSeconds()
. If ms is not present, this behaves as if ms was present with the value getMilliseconds()
.
This method performs the following steps when called:
The
If date is not present, this method behaves as if date was present with the value getDate()
.
This method performs the following steps when called:
The
If ms is not present, this method behaves as if ms was present with the value getMilliseconds()
.
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
The
If month is not present, this method behaves as if month was present with the value getUTCMonth()
. If date is not present, it behaves as if date was present with the value getUTCDate()
.
This method performs the following steps when called:
The
If min is not present, this method behaves as if min was present with the value getUTCMinutes()
. If sec is not present, it behaves as if sec was present with the value getUTCSeconds()
. If ms is not present, it behaves as if ms was present with the value getUTCMilliseconds()
.
This method performs the following steps when called:
This method performs the following steps when called:
The
If sec is not present, this method behaves as if sec was present with the value getUTCSeconds()
. If ms is not present, it behaves as if ms was present with the value return by getUTCMilliseconds()
.
This method performs the following steps when called:
The
If date is not present, this method behaves as if date was present with the value getUTCDate()
.
This method performs the following steps when called:
The
If ms is not present, this method behaves as if ms was present with the value getUTCMilliseconds()
.
This method performs the following steps when called:
This method performs the following steps when called:
This method provides a String representation of a Date for use by JSON.stringify
(
It performs the following steps when called:
The argument is ignored.
This method is intentionally generic; it does not require that its toISOString
method.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method returns a String value. The contents of the String are
The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method returns a String value. The contents of the String are
The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method returns a String value. The contents of the String are
The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
For any Date d
such that d.[[DateValue]]
is evenly divisible by 1000, the result of Date.parse(d.toString())
= d.valueOf()
. See
This method is not generic; it throws a
The abstract operation TimeString takes argument tv (a Number, but not
The abstract operation DateString takes argument tv (a Number, but not
Number | Name |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Number | Name |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The abstract operation TimeZoneString takes argument tv (an
The abstract operation ToDateString takes argument tv (an
This method performs the following steps when called:
This method returns a String value representing the instant in time corresponding to the
It performs the following steps when called:
This method performs the following steps when called:
This method is called by ECMAScript language operators to convert a Date to a primitive value. The allowed values for hint are
It performs the following steps when called:
This property has the attributes { [[Writable]]:
The value of the
Date instances are