乱码时光

个人收藏夹

Javascript 判断空值 undefined 和 null

2019-10-11 admin

Javascript 判断 undefined
const a = undefined
if (typeof(a) == "undefined")
{
  alert("undefined")
}

Javascript 判断 null
const a = null
if (!a && typeof(a) != "undefined" && a != 0)
{
  alert("is null");
}