Open In App

JavaScript DataView.getBigUint64() Method

Last Updated : 10 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

dataview.getBigUint64(byteOffset [, 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.
  • littleEndian: It is an optional parameter. If it is true then it 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: It returns a BigInt value.

Example 1: In this example, the offset passed is 0, so the value printed is 0 because the value is not set.

Javascript




<script>
    // Creating buffer with size in byte
    var buffr = new ArrayBuffer(16);
       
    // Creating a view
    var dView = new DataView(buffr);
       
    // Getting the value
    console.log(dView.getBigUint64(0));
</script>


Output:

0

Example 2: In this example, the offset passed is 4, so the value printed is 1234 because it is set before.

Javascript




<script>
    // Create an ArrayBuffer with a size in bytes
    const buffr = new ArrayBuffer(16);
       
    // A value to set
    const val = 1234n;
    const view = new DataView(buffr);
       
    view.setBigUint64(4, val);
       
    // Getting the value
    console.log(view.getBigUint64(4));
</script>


Output:

1234

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads