JavaScript DataView() Last Updated : 30 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The DataView function in JavaScript provides an interface to read and write more than one number types into an ArrayBuffer. Syntax:new DataView(buffer, byteOffset, byteLength)Parameters: The function accepts three parameters which are described as below: buffer: An ArrayBuffer that is already existing to store the new DataView object.byteOffset (optional): offset(in bytes) in the buffer is used to start a new view of the buffer. By default, the new view starts from the first byte.byteLength (optional): It represents number of elements in the byte array. By default, the buffer’s length is considered as the length of the view.Return value: It returns a new DataView object which will represent the specified data buffer. Example: This example shows the use of the JavaScript DataView() function. javascript // Creating an ArrayBuffer with a size in bytes let buffer = new ArrayBuffer(16); // Creating views let view1 = new DataView(buffer); // Creating view from byte 0 for the next 4 bytes let view2 = new DataView(buffer, 0, 4); // Creating view from byte 12 for the next 2 bytes let view3 = new DataView(buffer, 12, 2); // Putting 1 in slot 0 view1.setInt8(0, 1); // Putting 2 in slot 12 view1.setInt8(12, 2); // Printing the views console.log(view2.getInt8(0)); console.log(view3.getInt8(0)); Output:12 Comment More infoAdvertise with us Next Article JavaScript dataView.getUint8() Method V vidhyachaudhary Follow Improve Article Tags : JavaScript Web Technologies Similar Reads JavaScript DataView Reference JavaScript dataView is used to control how we can access data, regardless of executing endianness. And provides an interface to read and write more than one number types into an ArrayBuffer. Syntax: new DataView(buffer, byteOffset, byteLength) Example: JavaScript code to show the working of dataView 3 min read JavaScript dataView.getInt8() Method The dataView.getInt8() is a method in dataView which is used to get an 8-bit integer in the byte at the specified location from the start of the dataView. Syntax: dataview.getInt8(byteOffset) Parameters: It has the parameter byteOffset which is offset in a byte and it says from the start of the view 2 min read JavaScript dataView.setInt8() Method The dataView.setInt8() is an inbuilt function in dataView that is used to store a signed 8-bit integer at the specified location i.e, at byte offset from the start of the dataView. Syntax: dataView.setInt8(byteOffset) Parameters: It has the parameter byteOffset which is offset in byte i.e from the s 2 min read JavaScript dataView.setUint8() Method The dataView.setUint8() is an inbuilt function in dataView that is used to store an unsigned 8-bit integer at the specified location i.e, at byte offset from the start of the dataView. Syntax: dataView.setUint8(byteOffset) Parameters: It has the parameter byteOffset which is offset in a byte and it 2 min read JavaScript dataView.getUint8() Method The dataView.getUint8() is an inbuilt function in dataView that is used to get an unsigned 8-bit integer at the specified location i.e, at byte offset from the start of the dataView. Syntax: dataView.getUint8(byteOffset) Parameters: It has the parameter byteOffset which is offset in a byte and it sa 2 min read JavaScript dataView.setInt16() Method The dataView.setInt16() is an inbuilt function in dataView that is used to store a signed 16-bit integer at the specified location i.e at byte offset from the start of the dataView. Syntax: dataView.setInt16(byteOffset) Parameters: It has the parameter byteOffset which is offset in a byte and it say 2 min read Like