![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DataView.setInt32() function in JavaScript
The setInt32() function of the DataView stores a signed 32-bit integer at the specified position.
Syntax
Its syntax is as follows
dataView.setInt32();
Example
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new ArrayBuffer(20); var dataView = new DataView(arrayBuffer); dataView.setInt32(1, 36274722); document.write(dataView.getInt32(1)); </script> </body> </html>
Output
36274722
Example
To this function you cannot pass float value, if you try to do so it is considered as integer value.
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new ArrayBuffer(20); var dataView = new DataView(arrayBuffer); dataView.setInt32(1, 554.36); document.write(dataView.getInt32(1)); </script> </body> </html>
Output
554
Example
If nothing is stored in the dataview and if you still, try to get data, this function will return 0.
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new ArrayBuffer(20); var dataView = new DataView(arrayBuffer); dataView.setInt32(1); document.write(dataView.getInt32(1)); </script> </body> </html>
Output
0
Advertisements