Open In App

JavaScript DataView.setBigUint64() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The setBigUint64() method is used to store an unsigned 64-bit integer (unsigned long long) value at the particular byte offset from the start of the DataView.

Syntax:

dataview.setBigUint64(byteOffset, val [, littleEndian])

Parameters: This method accepts two parameters as mentioned above and described below: 

  • byteOffset: This parameter specifies the offset, in bytes, from the start of the view to read the data.
  • val: This parameter specifies the value to set as a BigUInt.
  • littleEndian: It is an optional parameter. If it is true then indicates if the 64-bit int is stored in little- or big-endian format. If set to false or not-defined, then a big-endian value is read. 

Return Value: This function returns undefined.

Example 1: In this example, the value set is 1234 at offset 0.

Javascript




<script>
    var buffer = new ArrayBuffer(8);
    var dView = new DataView(buffer);
    dView.setBigUint64(0, 1234n);
    console.log(dView.getBigUint64(0));
</script>


Output:

1234

Example 2: In this example, the value set is 12345678 at offset 6.

Javascript




<script>
    // Creating an ArrayBuffer with a size in bytes
    const buffer = new ArrayBuffer(32);
    // Setting constant value
    const val = 12345678n;
    const dView = new DataView(buffer);
    dView.setBigUint64(6, val);
    console.log(dView.getBigUint64(6));
</script>


 Output:

12345678

We have a complete list of Javascript Boolean and Dataview Methods, to check those please go through Javascript Boolean and DataView Complete Reference article.

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

Last Updated : 10 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads