![]() |
VOOZH | about |
JavaScript handler.has() method in JavaScript is used to "hide" any property that you want. It is a trap for in operator. It returns the Boolean value. If you want to access the property, it returns the Boolean value true; otherwise, it returns false. Whether the key was included with the original object or not.
Syntax:
const p = new Proxy(target, {
has: function(target, prop) {
}
});
Parameters: This method accepts two parameters as mentioned above and described below:
Return value: This method returns a Boolean value true if you want the property to be accessed.
Below examples illustrate the handler.has() method in JavaScript:
Example 1: In this example, we will check if the object has the values or not using the handler.has() method in JavaScript.
Output:
true false true
Example 2: In this example, we will check if the object has the values or not using the handler.has() method in JavaScript.
Output:
"prop" false "prop" true
Supported Browsers: The browsers supported by handler.has() method are listed below:
We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.