美文网首页
2021-12-10判断对象obj是否为空

2021-12-10判断对象obj是否为空

作者: ClarkM | 来源:发表于2021-12-10 15:53 被阅读0次

判断对象obj是否为空

const isEmpty = obj => Reflect.ownKeys(obj).length === 0 && obj.constructor === Object

console.log(isEmpty( { } ) )  // true

console.log( isEmpty( { name : "小明" } ) )  // false

获取两个日期之间的天数差

const daysBetween = (date1, date2){

  return Math.ceil(Math.abs(date1 - date2) / (1000 * 60 * 60 * 24) )

}

相关文章

网友评论

      本文标题:2021-12-10判断对象obj是否为空

      本文链接:https://www.haomeiwen.com/subject/thbcfrtx.html