Node.js – util.types.isArgumentsObject() Method


The util.types.isArgumentsObject() method checks whether the passed value is an arguments object or not. If the above condition is satisfied, it returns True, else False.

Syntax

util.types.isArgumentsObject( value )

Parameters

  • value − This input parameter takes input for the required parameter and checks if it's an arguments object or not.

It returns True or False based upon the input value passed.

Example 1

Create a file with the name "isArgumentsObject.js" and copy the following code snippet. After creating the file, use the command "node isArgumentsObject.js" to run this code.

// util.types.isArgumentsObject() Demo Example

// Importing the util module
const util = require('util');

// Passing the arguments object
console.log("1. " + util.types.isArgumentsObject(arguments));

// Passing a object with data
var args = {name1: "Tutorials", name2: "Point"}
console.log("2. " + util.types.isArgumentsObject(args));

// Passing an empty object
console.log("3." + util.types.isArgumentsObject(new Object()));

Output

C:\home
ode>> node isArgumentsObject.js 1. true 2. false 3. false

Example 2

// util.types.isArgumentsObject() Demo Example

// Importing the util module
const util = require('util');

// Defining some arguments value
arguments[0] = 1;
arguments[1] = 2;
arguments.length = 3;

// Passing the arguments object
console.log("1. " + util.types.isArgumentsObject(arguments));

// Passing argument value
console.log("2. " + util.types.isArgumentsObject(arguments[0]));

// Passing argumnets as Array
const args = Array.from(arguments);
console.log("3. " + util.types.isArgumentsObject(args));

// Passing array protoype for arguments
const args1 = Array.prototype.slice.call(arguments);
console.log("4. " + util.types.isArgumentsObject(args1));

Output

C:\home
ode>> node isArgumentsObject.js 1. true 2. false 3. false 4. false

Updated on: 17-Aug-2021

38 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements