获得徽章 0
- Functions defined with => are always anonymous, while functions defined with function can optionally be named. Naming can be very helpful in stack traces when debugging, so I recommend using named functions when exporting a function from a file with the export keyword.展开评论2
- // 比较日期是否在同一天
function isSameDay(timeA, timeB) {
// 获取两个时间的0点时间戳
let dateA = new Date(timeA + '').setHours(0, 0, 0, 0)
let dateB = new Date(timeB + '').setHours(0, 0, 0, 0)
// 比较时间戳
return dateA === dateB
}
const t1 = '2022-03-23 17:32'
const t2 = '2022-03-23 08:11'
console.log(isSameDay(t1, t2))展开42
![[嘿哈]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_67.9ceed33.png)
![[呲牙]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_2.cd1e2bd.png)