typeof,instanceof

1.typeof

typeof运算符返回的结果是以小写的字符串表示的变量的类型

typeof,instanceof_第1张图片

typeof,instanceof_第2张图片

typeof,instanceof_第3张图片

2.instanceof

instanceof运算符用于判断右边构造函数的原型对象是否在左边对象的原型链上

        let arr=[]
        let obj={}
        let date=new Date
        console.log(arr instanceof Array)
        console.log(arr instanceof Object)
        console.log(arr instanceof RegExp)
        console.log(obj instanceof Array)
        console.log(obj instanceof Object)
        console.log(obj instanceof RegExp)
        console.log(date instanceof Array)
        console.log(date instanceof Object)
        console.log(date instanceof Date)

typeof,instanceof_第4张图片

你可能感兴趣的:(JavaScript,javascript,前端,vue.js)