Open In App

JavaScript DataView.setBigUint64() Method

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: 

Return Value: This function returns undefined.



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




<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.




<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:

Article Tags :