Skip to content

Home > robinson > isLeapYear

isLeapYear() function

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

判断给定年份是否为闰年。

Signature:

typescript
declare function isLeapYear(year: string | number): boolean;
declare function isLeapYear(year: string | number): boolean;

Parameters

ParameterTypeDescription
yearstring | number要判断的年份,可以是字符串或数字。

Returns:

boolean

{boolean} - 如果是闰年返回 true,否则返回 false。

Example

javascript
isLeapYear('2024') // true
isLeapYear('2025') // false
isLeapYear('2024') // true
isLeapYear('2025') // false

Released under the MIT License.