Reflect.has()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
TheReflect.has() static method is like thein operator, butas a function.
In this article
Try it
const object = { property1: 42,};console.log(Reflect.has(object, "property1"));// Expected output: trueconsole.log(Reflect.has(object, "property2"));// Expected output: falseconsole.log(Reflect.has(object, "toString"));// Expected output: trueSyntax
js
Reflect.has(target, propertyKey)Parameters
targetThe target object in which to look for the property.
propertyKeyThe name of the property to check.
Return value
ABoolean indicating whether or not thetarget has the property.
Exceptions
TypeErrorThrown if
targetis not an object.
Description
Reflect.has() provides the reflective semantic of checking if a property is in an object. That is,Reflect.has(target, propertyKey) is semantically equivalent to:
js
propertyKey in target;Reflect.has() invokes the[[HasProperty]]object internal method oftarget.
Examples
>Using Reflect.has()
js
Reflect.has({ x: 0 }, "x"); // trueReflect.has({ x: 0 }, "y"); // false// returns true for properties in the prototype chainReflect.has({ x: 0 }, "toString");// Proxy with .has() handler methodobj = new Proxy( {}, { has(t, k) { return k.startsWith("door"); }, },);Reflect.has(obj, "doorbell"); // trueReflect.has(obj, "dormitory"); // falseReflect.has returnstrue for any inherited properties, like thein operator:
js
const a = { foo: 123 };const b = { __proto__: a };const c = { __proto__: b };// The prototype chain is: c -> b -> aReflect.has(c, "foo"); // trueSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-reflect.has> |