Temporal.Instant.prototype.equals()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.

Die equals() Methode von Temporal.Instant Instanzen gibt true zurück, wenn dieses Instant zeitlich gleichwertig mit einem anderen Instant ist (in einer Form, die durch Temporal.Instant.from() konvertierbar ist), und false andernfalls. Sie werden durch ihre epochNanoseconds verglichen. Dies entspricht Temporal.Instant.compare(this, other) === 0.

Syntax

js
equals(other)

Parameter

other

Ein String oder eine Temporal.Instant Instanz, die das andere zu vergleichende Instant darstellt. Es wird mit demselben Algorithmus wie Temporal.Instant.from() in ein Temporal.Instant Objekt konvertiert.

Rückgabewert

true, wenn dieses Instant nanosekunden-genau zu other gleichwertig ist, andernfalls false.

Beispiele

Verwendung von equals()

js
const instant1 = Temporal.Instant.from("2021-08-01T12:34:56Z");
const instant2 = Temporal.Instant.fromEpochMilliseconds(1627821296000);
console.log(instant1.equals(instant2)); // true

Spezifikationen

Specification
Temporal
# sec-temporal.instant.prototype.equals

Browser-Kompatibilität

Siehe auch