DataView.prototype.setBigUint64()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

The setBigUint64() method of DataView instances takes a BigInt and stores it as a 64-bit unsigned integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds.

Try it

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);

// Highest possible BigInt value that fits in an unsigned 64-bit integer
const max = 2n ** 64n - 1n;

const view = new DataView(buffer);
view.setBigUint64(1, max);

console.log(view.getBigUint64(1));
// Expected output: 18446744073709551615n

Syntax

js
setBigUint64(byteOffset, value)
setBigUint64(byteOffset, value, littleEndian)

Parameters

byteOffset

The offset, in bytes, from the start of the view to store the data in.

value

The value to set as a BigInt. For how the value is encoded in bytes, see Value encoding and normalization.

littleEndian Optional

Indicates whether the data is stored in little- or big-endian format. If false or undefined, a big-endian value is written.

Return value

undefined.

Exceptions

RangeError

Thrown if the byteOffset is set such that it would store beyond the end of the view.

Examples

Using setBigUint64()

js
const buffer = new ArrayBuffer(10);
const dataview = new DataView(buffer);
dataview.setBigUint64(0, 3n);
dataview.getBigUint64(1); // 768n

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-dataview.prototype.setbiguint64

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
setBigUint64
Chrome – Full support
Chrome 67 (Release date: 2018-05-29)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 68 (Release date: 2019-07-09)
footnote Full support
Opera – Full support
Opera 54 (Release date: 2018-06-28)
footnote Full support
Safari – Full support
Safari 15 (Release date: 2021-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 67 (Release date: 2018-05-31)
footnote Full support
Firefox for Android – Full support
Firefox for Android 68 (Release date: 2019-07-09)
footnote Full support
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote Full support
WebView Android – Full support
WebView Android 67 (Release date: 2018-05-31)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15 (Release date: 2021-09-20)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 10.4 (Release date: 2018-06-06)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also