Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

JavaScript DataView.setBigUint64() Method

  • Last Updated : 31 Aug, 2020

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:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

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

Parameters: This method accept 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.

HTML




<script>
    var buffr = new ArrayBuffer(8);
    var dView = new DataView(buffr);
    dView.setBigUint64(0, 1234n);
    document.write(dView.getBigUint64(0));
</script>

Output:

1234

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

HTML




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

Output:

12345678
My Personal Notes arrow_drop_up
Recommended Articles
Page :