Skip to content
Related Articles

Related Articles

Improve Article

JavaScript dataView.setBigInt64() method

  • Last Updated : 09 Sep, 2020
Geek Week

This setBigInt64() method is used to store a signed 64-bit integer (long long) value at the particular byte offset from the start of the DataView.

Syntax:

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

Parameters:

  • 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 BigInt.
  • littleEndian: This is 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 does not return anything.



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




<script>
    var buffr = new ArrayBuffer(8);
    var dView = new DataView(buffr);
    dView.setBigInt64(0, 7n);
    document.write(dView.getBigInt64(0));
</script>

Output:

7

Example 2: In this example, the value set is 789 at offset 4.




<script>
    // create an ArrayBuffer with a size in bytes
    const buffr = new ArrayBuffer(16);
    // constant value to set
    const val = 789n;
    const dView = new DataView(buffr);
    dView.setBigInt64(4, val);
    document.write(dView.getBigInt64(4));
</script>

Output:

789

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!

My Personal Notes arrow_drop_up
Recommended Articles
Page :