Temporal.PlainTime.prototype.equals()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Phương thức equals() của các thực thể Temporal.PlainTime trả về true nếu thời gian này có giá trị tương đương với một thời gian khác (dưới dạng có thể chuyển đổi bởi Temporal.PlainTime.from()), ngược lại là false. Chúng được so sánh theo giá trị thời gian. Nó tương đương với Temporal.PlainTime.compare(this, other) === 0.
Cú pháp
js
equals(other)
Tham số
other-
Một chuỗi, một đối tượng, hoặc một thực thể
Temporal.PlainTimeđại diện cho thời gian khác cần so sánh. Nó được chuyển đổi thành đối tượngTemporal.PlainTimebằng cùng thuật toán nhưTemporal.PlainTime.from().
Giá trị trả về
true nếu thời gian này bằng other cả về giá trị thời gian lẫn lịch, false nếu không.
Ví dụ
>Sử dụng equals()
js
const time1 = Temporal.PlainTime.from("12:34:56");
const time2 = Temporal.PlainTime.from({ hour: 12, minute: 34, second: 56 });
console.log(time1.equals(time2)); // true
const time3 = Temporal.PlainTime.from("00:34:56");
console.log(time1.equals(time3)); // false
Đặc tả
| Specification |
|---|
| Temporal> # sec-temporal.plaintime.prototype.equals> |