?
u
m
/
The Number
extends
clause of a class definition. Subclass super
call to the Number When Number
is called with argument value, the following steps are taken:
The Number
The value of Number.EPSILON
is the
This property has the attributes { [[Writable]]:
When Number.isFinite
is called with one argument number, the following steps are taken:
When Number.isInteger
is called with one argument number, the following steps are taken:
When Number.isNaN
is called with one argument number, the following steps are taken:
This function differs from the global isNaN function (
When Number.isSafeInteger
is called with one argument number, the following steps are taken:
The value of Number.MAX_SAFE_INTEGER
is the largest
The value of Number.MAX_SAFE_INTEGER
is
This property has the attributes { [[Writable]]:
The value of Number.MAX_VALUE
is the largest positive finite value of the Number type, which is approximately
This property has the attributes { [[Writable]]:
The value of Number.MIN_SAFE_INTEGER
is the smallest
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 Number type, which is approximately
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 abstract operation thisNumberValue takes argument value. It performs the following steps when called:
The phrase “this
The initial value of Number.prototype.constructor
is
Return a String containing this
For implementations that provide more accurate conversions than required by the rules above, it is recommended that the following alternative version of step
toFixed
returns a String containing this
The following steps are performed:
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 the Number.prototype.toLocaleString
method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString
method is used.
Produces a String value that represents this 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.
Return a String containing this
The optional radix should be an
The following steps are performed:
a
-z
are used for digits with values 10 through 35. The precise algorithm is The toString
function is not generic; it throws a
The toString
method is
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 When BigInt
is called with argument value, the following steps are taken:
The abstract operation NumberToBigInt takes argument number (a Number) and returns either a
The BigInt
When the BigInt.asIntN
function is called with two arguments bits and bigint, the following steps are taken:
When the BigInt.asUintN
function is called with two arguments bits and bigint, the following steps are taken:
The initial value of BigInt.prototype
is the
This property has the attributes { [[Writable]]:
The BigInt prototype object:
The abstract operation thisBigIntValue takes argument value. It performs the following steps when called:
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 the BigInt.prototype.toLocaleString
method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString
method is used.
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
The following steps are performed:
a
-z
are used for digits with values 10 through 35. The precise algorithm is The toString
function is not generic; it throws a
The initial value of the
This property has the attributes { [[Writable]]:
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
, sqrt
, 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).
Returns the absolute value of x; the result has the same magnitude as x but has positive sign.
When the Math.abs
method is called with argument x, the following steps are taken:
Returns the inverse cosine of x. The result is expressed in radians and ranges from
When the Math.acos
method is called with argument x, the following steps are taken:
Returns the inverse hyperbolic cosine of x.
When the Math.acosh
method is called with argument x, the following steps are taken:
Returns the inverse sine of x. The result is expressed in radians and ranges from
When the Math.asin
method is called with argument x, the following steps are taken:
Returns the inverse hyperbolic sine of x.
When the Math.asinh
method is called with argument x, the following steps are taken:
Returns the inverse tangent of x. The result is expressed in radians and ranges from
When the Math.atan
method is called with argument x, the following steps are taken:
Returns the inverse hyperbolic tangent of x.
When the Math.atanh
method is called with argument x, the following steps are taken:
Returns the inverse tangent of the quotient
When the Math.atan2
method is called with arguments y and x, the following steps are taken:
Returns the cube root of x.
When the Math.cbrt
method is called with argument x, the following steps are taken:
Returns the smallest (closest to -∞)
When the Math.ceil
method is called with argument x, the following steps are taken:
The value of Math.ceil(x)
is the same as the value of -Math.floor(-x)
.
When the Math.clz32
method is called with argument x, the following steps are taken:
If n is
Returns the cosine of x. The argument is expressed in radians.
When the Math.cos
method is called with argument x, the following steps are taken:
Returns the hyperbolic cosine of x.
When the Math.cosh
method is called with argument x, the following steps are taken:
The value of Math.cosh(x)
is the same as the value of (Math.exp(x) + Math.exp(-x)) / 2
.
Returns the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
When the Math.exp
method is called with argument x, the following steps are taken:
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.
When the Math.expm1
method is called with argument x, the following steps are taken:
Returns the greatest (closest to +∞)
When the Math.floor
method is called with argument x, the following steps are taken:
The value of Math.floor(x)
is the same as the value of -Math.ceil(-x)
.
When the Math.fround
method is called with argument x, the following steps are taken:
Returns the square root of the sum of squares of its arguments.
When the Math.hypot
method is called with zero or more arguments which form the rest parameter ...args, the following steps are taken:
The hypot
method is
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.
When Math.imul
is called with arguments x and y, the following steps are taken:
Returns the natural logarithm of x.
When the Math.log
method is called with argument x, the following steps are taken:
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.
When the Math.log1p
method is called with argument x, the following steps are taken:
Returns the base 10 logarithm of x.
When the Math.log10
method is called with argument x, the following steps are taken:
Returns the base 2 logarithm of x.
When the Math.log2
method is called with argument x, the following steps are taken:
Given zero or more arguments, calls
When the Math.max
method is called with zero or more arguments which form the rest parameter ...args, the following steps are taken:
The comparison of values to determine the largest value is done using the
The max
method is
Given zero or more arguments, calls
When the Math.min
method is called with zero or more arguments which form the rest parameter ...args, the following steps are taken:
The comparison of values to determine the largest value is done using the
The min
method is
When the Math.pow
method is called with arguments base and exponent, the following steps are taken:
Returns a
Each Math.random
function created for distinct
Returns the
When the Math.round
method is called with argument x, the following steps are taken:
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 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
.
Returns the sign of x, indicating whether x is positive, negative, or zero.
When the Math.sign
method is called with argument x, the following steps are taken:
Returns the sine of x. The argument is expressed in radians.
When the Math.sin
method is called with argument x, the following steps are taken:
Returns the hyperbolic sine of x.
When the Math.sinh
method is called with argument x, the following steps are taken:
The value of Math.sinh(x)
is the same as the value of (Math.exp(x) - Math.exp(-x)) / 2
.
Returns the square root of x.
When the Math.sqrt
method is called with argument x, the following steps are taken:
Returns the tangent of x. The argument is expressed in radians.
When the Math.tan
method is called with argument x, the following steps are taken:
Returns the hyperbolic tangent of x.
When the Math.tanh
method is called with argument x, the following steps are taken:
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))
.
Returns the integral part of the number x, removing any fractional digits. If x is already integral, the result is x.
When the Math.trunc
method is called with argument x, the following steps are taken:
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 is a Number, either a finite
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
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.
A given
where the number of milliseconds per day is
The remainder is called the time within the day:
ECMAScript uses a proleptic Gregorian calendar to map a day number to a year number and to determine the month and date within that year. In this calendar, leap years are precisely those which are (divisible by 4) and ((not divisible by 100) or (divisible by 400)). The number of days in year number y is therefore defined by
All non-leap years have 365 days with the usual number of days per month and leap years have an extra day in February. The day number of the first day of year y is given by:
The
A
The leap-year function is
Months are identified by an
where
A month value of
A date number is identified by an
The weekday for a particular
A weekday value of
The
When isUTC is true,
When isUTC is false,
Input t is nominally a
When
If an implementation does not support a conversion described above or if political rules for time t are not available within the implementation, the result must be
It is recommended that implementations use the time zone information of the IANA Time Zone Database https://www.iana.org/time-zones/.
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. LocalTZA(
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). LocalTZA(
Local time zone offset values may be positive or negative.
The abstract operation LocalTime takes argument t (a
Two different input
The abstract operation UTC takes argument t (a Number) and returns a
The following
where
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:
*
+
m *
+
s *
+
milli, performing the arithmetic according to *
and +
).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 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 (indicating local time ahead of or behind UTC, respectively)
|
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. |
The Date
extends
clause of a class definition. Subclass super
call to the Date When the Date
function is called, the following steps are taken:
parse
method (The Date
The now
function returns the now
.
The parse
function applies the parse
interprets the resulting String as a date and time; it returns a Number, the UTC Date.parse
to return
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 Date.parse
is toString
or toUTCString
method.
The initial value of Date.prototype
is the
This property has the attributes { [[Writable]]:
When the UTC
function is called, the following steps are taken:
The UTC
function is
The UTC
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 abstract operation thisTimeValue takes argument value. It performs the following steps when called:
In following descriptions of functions that are properties of the Date prototype object, the phrase “this Date object” refers to the object that is the
The initial value of Date.prototype.constructor
is
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The following steps are performed:
The setFullYear
method is
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()
.
The following steps are performed:
The setHours
method is
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()
.
The following steps are performed:
The following steps are performed:
The setMinutes
method is
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()
.
The following steps are performed:
The setMonth
method is
If date is not present, this method behaves as if date was present with the value getDate()
.
The following steps are performed:
The setSeconds
method is
If ms is not present, this method behaves as if ms was present with the value getMilliseconds()
.
The following steps are performed:
The following steps are performed:
The following steps are performed:
The setUTCFullYear
method is
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()
.
The following steps are performed:
The setUTCHours
method is
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()
.
The following steps are performed:
The following steps are performed:
The setUTCMinutes
method is
If sec is not present, this method behaves as if sec was present with the value getUTCSeconds()
. If ms is not present, it function behaves as if ms was present with the value return by getUTCMilliseconds()
.
The following steps are performed:
The setUTCMonth
method is
If date is not present, this method behaves as if date was present with the value getUTCDate()
.
The following steps are performed:
The setUTCSeconds
method is
If ms is not present, this method behaves as if ms was present with the value getUTCMilliseconds()
.
The following steps are performed:
If
This function provides a String representation of a Date for use by JSON.stringify
(
When the toJSON
method is called with argument key, the following steps are taken:
The argument is ignored.
The toJSON
function is intentionally generic; it does not require that its toISOString
method.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Date.prototype.toLocaleDateString
method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleDateString
method is used.
This function 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 the Date.prototype.toLocaleString
method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString
method is used.
This function 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 the Date.prototype.toLocaleTimeString
method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleTimeString
method is used.
This function 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.
The following steps are performed:
For any Date d
such that d.[[DateValue]]
is evenly divisible by 1000, the result of Date.parse(d.toString())
= d.valueOf()
. See
The toString
function 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 (a Number, but not
The abstract operation ToDateString takes argument tv (a Number) and returns a String. It performs the following steps when called:
The following steps are performed:
The toUTCString
method returns a String value representing the instance in time corresponding to
The following steps are performed:
This function is called by ECMAScript language operators to convert a Date to a primitive value. The allowed values for hint are
When the @@toPrimitive
method is called with argument hint, the following steps are taken:
This property has the attributes { [[Writable]]:
The value of the
Date instances are