JS基础 undefiend 和null 相同点和不同点面试题

152 阅读1分钟

undefiend 和null 相同点和不同点

     undefiend 和null共同点: 值相等.转布尔类型都是false
    // console. log (undefined==null ) //true
    // console.log(Boolean(undefined))//false
    // console.log(Boolean(null)) //false



    undefiend 和null 不同点:数据类型不同,转number类型值不同
    // console. log (undefined== null ) //false
    // console.log(Number(undefined))//NaN
    //  console.log(Number(null)) //0