Temporal.PlainYearMonth.prototype.year
year 访问器属性,属于 Temporal.PlainYearMonth 实例,返回一个整数,表示该年月相对于日历特定纪年年的起始年的年数。它依赖于 日历。
year 的 set 访问器是 undefined。你不能直接更改此属性。请使用 with() 方法创建一个具有所需新值的 Temporal.PlainYearMonth 新对象。
有关一般信息和更多示例,请参见 Temporal.PlainDate.prototype.year。
示例
使用 year
js
const ym = Temporal.PlainYearMonth.from("2021-07"); // ISO 8601 calendar
console.log(ym.year); // 2021
规范
| 规范 |
|---|
| Temporal # sec-get-temporal.plainyearmonth.prototype.year |
浏览器兼容性
加载中…
另见
Temporal.PlainYearMonthTemporal.PlainYearMonth.prototype.with()Temporal.PlainYearMonth.prototype.add()Temporal.PlainYearMonth.prototype.subtract()Temporal.PlainYearMonth.prototype.eraTemporal.PlainYearMonth.prototype.eraYearTemporal.PlainYearMonth.prototype.monthTemporal.PlainDate.prototype.year