Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.isDataView() Method
The util.types.isDataView() method checks whether the passed value is a built-in DataView instance or not. If the above condition is satisfied, it returns True, else False.
Syntax
util.types.isDataView(value)
Parameters
- value − This input value takes input for the required parameter and checks if it's a Data View instance or not.
It returns True or False based upon the input value passed.
Example 1
Create a file named "isDataView.js" and copy the following code snippet. After creating the file, use the command "node isDataView.js" to run this code.
// util.types.isDataView() Demo Example
// Importing the util module
const util = require('util');
const buffer = new ArrayBuffer(20);
// Passing an array buffer in data view
console.log("1." + util.types.isDataView(new DataView(buffer)));
// Passing an array buffer
console.log("2." + util.types.isDataView(buffer));
// Passing a Float64 Array Buffer
console.log("3." + util.types.isDataView(new Float64Array()));
Output
C:\home
ode>> node isDataView.js 1.true 2.false 3.false
Example 2
// util.types.isDataView() Demo Example
// Importing the util module
const util = require('util');
var buffer = new ArrayBuffer(16);
var view = new DataView(buffer, 0);
view.setInt16(1, 42);
view.getInt16(1); // 42
// Passing a data view
console.log("1." + util.types.isDataView(view));
// Passing an element retrieved from dataview
console.log("2." + util.types.isDataView(view.getInt16(1)));
// Passing an Array Buffer
console.log("3." + util.types.isDataView(new ArrayBuffer()));
Output
C:\home
ode>> node isDataView.js 1.true 2.false 3.false
Advertisements