Replies: 4 comments 6 replies
-
我认为大概率会被驳回
倒不如吧 idea 变更为获取 e.g: Symbol.getStringTag(....) |
Beta Was this translation helpful? Give feedback.
0 replies
-
遇到 |
Beta Was this translation helpful? Give feedback.
2 replies
-
另外是不是应该大写,否则无法区分 |
Beta Was this translation helpful? Give feedback.
4 replies
-
我记得之前会议上有讨论过 builtin 的 brand 问题,但是具体内容得翻翻会议纪要。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
现状
目前我们获取js标准内置对象实例类型的方式有多种,比如 typeof,instance of,Object.prototype.toString
缺点在于对数组、null和对象类型傻傻的分不清楚,返回的值都是object
缺点在于对基本数据类型不能判断准确,如 2 instanceof Number 是false
有些也不能提取出来,如 Promise,Map,Set的实例类型
因此,如果有一个新的操作符,如命名为 datatypeof,能提取出所有js标准内置对象实例类型就好了,因为我们是获取标准内置对象实例的类型,所以 在标准内置对象中没法实例化的就被排除了,如 属性、函数属性、Math。js标准内置对象请看:点我
例子:
`
datatypeof 123 === 'number'
datatypeof "foo" === 'string'
datatypeof true === 'boolean'
datatypeof undefined === 'undefined'
datatypeof 1n === 'bigint'
datatypeof Symbol(123) === 'symbol'
datatypeof null === 'null'
datatypeof {}=== 'object'
datatypeof /foo/ === 'regexp'
datatypeof new Date() === 'date'
datatypeof new Promise()==='promise'
等等
`
Beta Was this translation helpful? Give feedback.
All reactions