Below is the example of the dataView.setInt16() Method.
DataView(buffer, 0, 10);
The dataView.setInt16() is an inbuilt function in dataView which is used to store an signed 16-bit integer at the specified location i.e at byte offset from the start of the dataView.
Parameters: It has parameter byteOffset which is offset in a byte and it says where to read the data from the beginning(start) of the view.
Return value: This function does not return anything.
Input: dataview1.setInt16(1, 56); Output: 56
Input: dataview1.setInt16(1, Math.PI); Output: 3
This function does not accept float value that is why it converts float value to integer value. It can be seen from the output of the below program that program should give output as 3.14 (the value of PI) but this function convert this value to 3.
When there is no data to be stored, then it returns zero (0).
- Google Chrome
- Internet Explorer
- Apple Safari