The Reflect.has(object, property) method

The Reflect.has() is used to check if a property exists in an object. It also checks for the inherited properties. It returns true if the property exists. Otherwise, it returns false.

It's the same as the in operator in JavaScript.

Here is a code example that demonstrates how to use the Reflect.has() method:

var obj = {   __proto__: { name: "Eden" },   age: 12 }; console.log(Reflect.has(obj, "name")); //Output "true" console.log(Reflect.has(obj, "age")); //Output "true"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.