Reflect.has检测对象是否拥有某个属性

Reflect.has({x: 0}, 'x'); // true
Reflect.has({x: 0}, 'y'); // false

// returns true for properties in the prototype chain 
Reflect.has({x: 0}, 'toString');

// Proxy with .has() handler method
obj = new Proxy({}, {
  has(t, k) { return k.startsWith('door'); }
});
Reflect.has(obj, 'doorbell'); // true
Reflect.has(obj, 'dormitory'); // false

语法

Reflect.has(target, propertyKey)

参数

  target目标对象.propertyKey属性名,需要检查目标对象是否存在此属性。

异常

  如果目标对象并非 Object 类型,抛出 TypeError

链接:https://cloud.tencent.com/developer/section/1192037

那时候我只有一台录音机也没有电脑 也不敢奢求说唱会让自己的生活变好
原文地址:https://www.cnblogs.com/520BigBear/p/14315792.html