最近遇到一个面试题,判断一个变量是否有值,当时有点蒙,其实很简单,就是判断 变量是否为 undefined或者null
function isFlag(val) {
   if(Object.prototype.toString.call(val) == '[object Null]' || Object.prototype.toString.call(val) == '[object Undefined]') {
   return  false
   } else {
   return true
   }
}
let a = isFlag(null)
let b = isFlag(undefined)
console.log(a)
console.log(b)
// false
// false
// 函数 返回false 就是没有值,true 有值