
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
ArrayBuffer.isView Function in JavaScript
ArrayBuffer object in JavaScript represents a fixed-length binary data buffer. The isView() function of this object accepts an argument and verifies whether it is view of ArrayBuffer (DataView, typed array). If so, it returns true else, it returns false.
Syntax
Its syntax is as follows
arrayBuffer.isView(arg)
Example
Try the following example.
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new ArrayBuffer(5); arrayBuffer = ["apple", "orange", "mango"]; var bool = ArrayBuffer.isView(new Int32Array()) document.write(bool); </script> </body> </html>
Output
true
Example
In the same way if we try executing this function by passing an object other than typed array or, a null value or, undefined value this function returns false.
<html> <head> <title>JavaScript Example</title> </head> <body> <script> var arrayBuffer = new ArrayBuffer(5); arrayBuffer = ["apple", "orange", "mango"]; var bool1 = ArrayBuffer.isView(new Int32Array()); var bool2 = ArrayBuffer.isView(); var bool3 = ArrayBuffer.isView(null); var bool4 = ArrayBuffer.isView(undefined); console.log(bool1); console.log(bool2); console.log(bool3); console.log(bool4); </script> </body> </html>
Output
True false false false
Advertisements