Skip to content

Commit 0fff81e

Browse files
committed
feat: 修改了js代码段
1 parent 53de3c3 commit 0fff81e

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>isBeforeDate</title>
8+
</head>
9+
10+
<body>
11+
<script>
12+
const isBeforeDate = (dateA, dateB) => {
13+
if (dateA instanceof Date && dateB instanceof Date) {
14+
return dateA < dateB;
15+
}
16+
return false;
17+
};
18+
document.write(`isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21))的结果是:${isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21))}`)
19+
</script>
20+
</body>
21+
22+
</html>

codes/javascript/isBeforeDate.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
| 标题 | 标签 |
2-
| ---- | ---- |
1+
| 标题 | 标签 |
2+
| ---------------------------- | ---------- |
33
| isBeforeDate(日期比较(之前)) | date(日期) |
44

55
检查一个日期是否在另一个日期之后。
66

7-
* 使用大于运算符 (<) 检查第一个日期是否在第二个日期之后。
7+
- 使用大于运算符 (<) 检查第一个日期是否在第二个日期之后。
88

99
```js
10-
const isBeforeDate = (dateA,dateB) => {
11-
if(dateA instanceof Date && dateB instanceof Date){
12-
return dateA < dateB;
13-
}
14-
return false;
15-
}
10+
const isBeforeDate = (dateA, dateB) => {
11+
if (dateA instanceof Date && dateB instanceof Date) {
12+
return dateA < dateB;
13+
}
14+
return false;
15+
};
1616
```
1717

1818
> 调用方式:
@@ -23,7 +23,8 @@ isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21)); // true
2323

2424
> 应用场景
2525
26+
<div class="code-editor" data-url="codes/javascript/html/isBeforeDate.html" data-language="html"></div>
2627

28+
结果如下:
2729

28-
29-
30+
<iframe src="codes/javascript/html/isBeforeDate.html"></iframe>

0 commit comments

Comments
 (0)