lodash源码分析之getTag

70 阅读1分钟

一.getTag函数解析

(1) 知识点一

Object.protype.toString()
// 所有继承Object.protype对象,(null,undefined)除外都继承toString// 会根据对象的[[class]]内部属性,返回由'[object 和 class ]' 组成的字符串ps [[class]]是个啥   字面理解就是toString(xx) 这个xx类

(2)知识点二

value == null  
// 这里为什么不写 value === null 
   ps 写value === null 那么undefined 不会触发这个判断,还要多写一个判断
   ps 如果写value == null undefinednull 都会触发这个判断并且 undefined == null == true  
      因为undefinednull派生