Node.js | util.types.isArgumentsObject() Method
Last Updated :
14 Feb, 2020
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
const util = require( 'util' );
console.log(util.types.isArgumentsObject(arguments));
console.log(util.types.isArgumentsObject( new Object()));
console.log(util.types.isArgumentsObject(
{arg1: "Hello" , arg2: "World" }));
|
Output:
true
false
false
Example 2:
Node.js
const util = require( 'util' );
function exampleFn(arg1, arg2) {
let argumentsObj = arguments;
console.log(arguments);
isArgumentObj = util.types.isArgumentsObject(argumentsObj);
console.log( "Object is arguments object:" , isArgumentObj);
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...