Node.js | util.types.isArgumentsObject() Method
The util.types.isArgumentsObject() method is an inbuilt application programming interface of util module which is primarily designed to support the needs of Node.js own internal APIs.
The util.types.isArgumentsObject() method is used to check if the given value is an arguments object or not.
Syntax:
util.types.isArgumentsObject( value )
Parameters: This function accepts one parameter as mentioned above and described below:
- value: It is the value that would be checked for an arguments object.
Return Value: It returns a Boolean value i.e. true if the passed value is an arguments object otherwise returns false.
Below programs illustrate the util.types.isArgumentsObject() method in Node.js:
Example 1:
Node.js
// Node.js program to demonstrate the // util.types.isArgumentsObject() method // Import the util module const util = require( 'util' ); // Checking the arguments object console.log(util.types.isArgumentsObject(arguments)); // Checking new object created by the constructor console.log(util.types.isArgumentsObject( new Object())); // Checking a normal object console.log(util.types.isArgumentsObject( {arg1: "Hello" , arg2: "World" })); |
Output:
true false false
Example 2:
Node.js
// Node.js program to demonstrate the // util.types.isArgumentsObject() method // Import the util module const util = require( 'util' ); function exampleFn(arg1, arg2) { // Checking the arguments object let argumentsObj = arguments; console.log(arguments); isArgumentObj = util.types.isArgumentsObject(argumentsObj); console.log( "Object is arguments object:" , isArgumentObj); // Checking a normal object let normalObj = {arg1: "hello" , arg2: "world" }; console.log(normalObj); isArgumentObj = util.types.isArgumentsObject(normalObj); console.log( "Object is arguments object:" , isArgumentObj); } exampleFn( 'hello' , 'world' ); |
Output:
[Arguments] { '0': 'hello', '1': 'world' } Object is arguments object: true { arg1: 'hello', arg2: 'world' } Object is arguments object: false
Reference: https://nodejs.org/api/util.html#util_util_types_isargumentsobject_value
Contact Us