前端知识碎片🧩(持续更新)

57 阅读1分钟

1.bigint

BigInt是一种内置对象,它提供了一种方法来表示大于 2^53 - 1 的整数。这原本是 Javascript 中可以用 Number表示的最大数字。BigInt可以表示任意大的整数。

const theBiggestInt = 9007199254740991n
const alsoHuge = BigInt(9007199254740991)

2.instanceof

instanceof用来判断一个对象是不是由某个构造函数(或是该构造函数的父类)构造的

zhangsan instanceof Student // true
zhangsan instanceof People // true
zhangsan instanceof Object // true

原理:zhangsan的隐式原型能不能找到class对应的显式原型(一层一层往上查找),能找到则为true