Skip to content
Related Articles

Related Articles

Improve Article

JavaScript dataView.getBigInt64() method

  • Last Updated : 16 Sep, 2020
Geek Week

Below is the example of the dataView.setInt8() Method.

  • Example:




    <script>  
       var buffr = new ArrayBuffer(12);  
          
       var dataview = new DataView(buffr);   
       document.write(dataview.getBigInt64(0)); 
    </script>
  • Output:
    0

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

Syntax:

dataview.getBigInt64(byteOffset [, littleEndian])

Parameters:

  • byteOffset: This parameter specifies the offset, in bytes, from the start of the view to read the data.
  • 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: It returns a BigInt value.



Thrown Error: If the byteOffset is passed beyond the end of the view then the RangeError is thrown.

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




<script
   // Creating buffer with size in byte 
   var buffr = new ArrayBuffer(8); 
    
   // Creating a view 
   var dataview = new DataView(buffr);  
   document.write(dataview.getBigInt64(0));
</script>

Output:

0

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




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

Output:

10000

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera

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 :