instance of
最编程
2024-03-16 18:09:28
...
instance of 运算符用于检验构造函数的 prototype 属性是否出现在某个实例对象的原型链上
使用方法:
object instanceof constructor
object 为实例对象,constructor 为构造函数
构造函数通过 new
可以创建一个实例对象,instanceof
能判断这个实例对象是否是之前那个构造函数生成的对象
// 定义构建函数
let Car = function() {}
// 创建实例对象
let benz = new Car()
benz instanceof Car // true
let car = new String('xxx')
car instanceof String // true
let str = 'xxx'
str instanceof String // false
顺着原型链去找,直到找到相同的原型对象,返回true
,否则为false
推荐阅读
-
NX 二次开发-UFUN 有程序集实例名称,获取实例标记 UF_ASSEM_ask_instance_of_name
-
instance of
-
tencent cloud-Heterogeneous Computing Instance Family
-
标题:启动实例失败,nova-compute.log 报出 Instance failed network setup after 1 attempt(s)
-
Object reference not set to an instance of an object.
-
terminate called after throwing an instance of ‘std::invalid_argument‘ what: stoi Aborted
-
论文阅读:Mask3D: Mask Transformer for 3D Semantic Instance Segmentation