| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has | [Back] [Original] |
Get to know MDN better
const object = {
property1: 42,
};
console.log(Reflect.has(object, "property1"));
// : true
console.log(Reflect.has(object, "property2"));
// : false
console.log(Reflect.has(object, "toString"));
// : true
Reflect.has(target, propertyKey)
(Boolean)
TypeErrortarget
Reflect.has() Reflect.has(target, propertyKey)
propertyKey in target;
Reflect.has() target [[HasProperty]]
Reflect.has({ x: 0 }, "x"); // true
Reflect.has({ x: 0 }, "y"); // false
// true
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 true in
const a = { foo: 123 };
const b = { __proto__: a };
const c = { __proto__: b };
// The prototype chain is: c -> b -> a
Reflect.has(c, "foo"); // true
| ECMAScript 2027 LanguageSpecification # sec-reflect.has |
| Web Proxy Viewer | New URL | Original Page |