![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js β util.types.isProxy() Method
The util.types.isProxy() method checks whether the passed value is a built-in Proxy instance or not. If the above condition is satisfied, it returns True, else False.
Syntax
util.types.isProxy(value)
Parameters
It takes only one parameter −
value − This input value takes input for the required parameter and checks if it is a Proxy instance or not.
It returns True or False based upon the input value passed.
Example 1
Create a file "isProxy.js" and copy the following code snippet. After creating the file, use the command "node isProxy.js" to run this code.
// util.types.isProxy() Demo Example // Importing the util module const util = require('util'); // Defining proxy and target const target = {}; const proxy = new Proxy(target, {}); // Passing a target as input console.log("1. " + util.types.isProxy(target)); // Passing a Proxy instance as input console.log("2. " + util.types.isProxy(proxy));
Output
C:\home
ode>> node isFloat32Array.js 1. false 2. true
Example 2
// util.types.isProxy() Demo Example // Importing the util module const util = require('util'); // Defining proxy and target const handler = { get: function(obj, prop) { return prop in obj ? obj[prop] : 37; } }; const p = new Proxy({}, handler); p.a = 1; p.b = undefined; console.log(p.a, p.b); console.log('c' in p, p.c); // Passing a target as input console.log("1." + util.types.isProxy(handler)); // Passing a Proxy instance as input console.log("2." + util.types.isProxy(p));
Output
C:\home
ode>> node isInt8Array.js 1 undefined false 37 1.false 2.true
Advertisements