美文网首页
yck前端面试之道总结

yck前端面试之道总结

作者: 小呀么小二郎hhh | 来源:发表于2019-08-04 12:06 被阅读0次

    typeof vs instanceof 如何判断数据类型

    看到这一条面试题的时候,感觉还是不够理解。于是自己上网自己查了资料,记录一下。

    1⃣️ typeof

    typeof只能识别原始数据类型:number、string、boolean、undefine、null、symbol

    对于array、object,都只能识别出object

    2⃣️instanceof

    可以识别复杂类型,通过原型

    3⃣️Object.prototype.toString() 最好用

    相关文章

      网友评论

          本文标题:yck前端面试之道总结

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