JavaScript DataView Methods

Beginner
5 min read
Updated: Nov 2026
22 method guides
Method index

About This Index

This page is the JavaScript DataView Methods index for the tutorial track. Each row links to a full guide with syntax, three runnable examples, browser notes, and FAQs.

Learn what a DataView is and when to use it on /js/dataview. Use this page when you need one specific method, such as getUint8(), setUint16(), or getFloat32().

All methods come in get / set pairs.

Every number type has a get method that reads bytes and a set method that writes them. The name tells you the type and its size in bits: getInt16() reads a signed 16-bit (2-byte) whole number, setFloat64() writes an 8-byte decimal number. All of them are instance methods, so you call them on a view: view.getInt16(0).

How to Call a DataView Method

The first argument is always the byte offset: the position of the first byte, counted from the start of the view. Setters take the value second. Methods for 2 or more bytes accept a last littleEndian argument that picks the byte order (the default is big-endian):

JavaScript
const view = new DataView(new ArrayBuffer(8));

// write 2 bytes at offset 0, then read them back
view.setInt16(0, -300);
view.getInt16(0);                       // -300

// 4 bytes at offset 2, least significant byte first
view.setUint32(2, 4000000000, true);
view.getUint32(2, true);                // 4000000000
view.getUint32(2);                      // 2649070

// a 4-byte float at offset 4
view.setFloat32(4, 1.5);
view.getFloat32(4);                     // 1.5

Which Type Do I Need?

Pick the smallest type that can hold your values. “Int” types can be negative, “Uint” types (unsigned) start at 0, and “Float” types hold decimals.

TypeBytesValuesRead / write
Int81-128 to 127getInt8() / setInt8()
Uint810 to 255getUint8() / setUint8()
Int162-32768 to 32767getInt16() / setInt16()
Uint1620 to 65535getUint16() / setUint16()
Int324-2147483648 to 2147483647getInt32() / setInt32()
Uint3240 to 4294967295getUint32() / setUint32()
BigInt648-9223372036854775808n to 9223372036854775807ngetBigInt64() / setBigInt64()
BigUint6480n to 18446744073709551615ngetBigUint64() / setBigUint64()
Float16 (new)2about ±65504, about 3 digitsgetFloat16() / setFloat16()
Float324about ±3.4028234663852886e38, about 7 digitsgetFloat32() / setFloat32()
Float648about ±1.7976931348623157e308, about 15 to 17 digitsgetFloat64() / setFloat64()

JavaScript DataView Methods Table

All method guides in this JavaScript tutorial series (22 tutorials), grouped by what they do.

Read whole numbers (get)

6 methods

Read 1, 2, or 4 bytes as a whole number. The Int methods allow negative numbers; the Uint methods start at 0.

MethodDescriptionTutorial
getInt8()Read one byte as a signed whole number from -128 to 127.Open
getUint8()Read one byte as an unsigned whole number from 0 to 255.Open
getInt16()Read 2 bytes as a signed whole number from -32768 to 32767.Open
getUint16()Read 2 bytes as an unsigned whole number from 0 to 65535.Open
getInt32()Read 4 bytes as a signed whole number from -2147483648 to 2147483647.Open
getUint32()Read 4 bytes as an unsigned whole number from 0 to 4294967295.Open

Read big numbers (get)

2 methods

Read 8 bytes as a 64-bit whole number. These return a BigInt, such as 42n.

MethodDescriptionTutorial
getBigInt64()Read 8 bytes as a signed 64-bit whole number (returns a BigInt).Open
getBigUint64()Read 8 bytes as an unsigned 64-bit whole number (returns a BigInt).Open

Read decimals (get)

3 methods

Read 2, 4, or 8 bytes as a floating point number (a number with a fraction).

MethodDescriptionTutorial
getFloat16()Read 2 bytes as a 16-bit (half precision) floating point number. New in ES2025.Open
getFloat32()Read 4 bytes as a 32-bit (single precision) floating point number.Open
getFloat64()Read 8 bytes as a 64-bit (double precision) floating point number, the JavaScript Number format.Open

Write whole numbers (set)

6 methods

Write a whole number into 1, 2, or 4 bytes. Fractions are cut off and too-big values wrap around.

MethodDescriptionTutorial
setInt8()Write one byte as a signed whole number; out-of-range values wrap around.Open
setUint8()Write one byte as an unsigned whole number from 0 to 255; values wrap around.Open
setInt16()Write a signed 16-bit whole number into 2 bytes, big- or little-endian.Open
setUint16()Write an unsigned 16-bit whole number into 2 bytes; wraps at 65536.Open
setInt32()Write a signed 32-bit whole number into 4 bytes; decimals are truncated.Open
setUint32()Write an unsigned 32-bit whole number into 4 bytes; wraps at 4294967296.Open

Write big numbers (set)

2 methods

Write a BigInt into 8 bytes. A plain Number throws a TypeError.

MethodDescriptionTutorial
setBigInt64()Write a signed 64-bit BigInt into 8 bytes; Numbers throw a TypeError.Open
setBigUint64()Write an unsigned 64-bit BigInt into 8 bytes; wraps around at 2^64.Open

Write decimals (set)

3 methods

Write a number into 2, 4, or 8 bytes of floating point. Smaller types round the value.

MethodDescriptionTutorial
setFloat16()Write a number as a 16-bit (half precision) float; rounds to about 3 digits. New in ES2025.Open
setFloat32()Write a number as a 32-bit (single precision) float; rounds to about 7 digits.Open
setFloat64()Write a number as a 64-bit (double precision) float; stored exactly, no rounding.Open

Frequently Asked Questions

Twenty-two: eleven getters (getInt8, getUint8, getInt16, getUint16, getInt32, getUint32, getBigInt64, getBigUint64, getFloat16, getFloat32, getFloat64) and the eleven matching setters.
Start with getUint8() and setUint8(). They handle a single byte, need no byte-order argument, and show how offsets work before you move on to the 2-, 4- and 8-byte methods.
Byte order only matters when a number is split across several bytes. A 1-byte value has nothing to reorder, so getInt8(), getUint8(), setInt8() and setUint8() take only the offset (and the value).
Only getBigInt64() and getBigUint64(). Their setters, setBigInt64() and setBigUint64(), also require a BigInt value such as 10n.
getFloat16() and setFloat16() were added in ES2025. The BigInt methods arrived in ES2020, and all the others have existed since ES2015.

Start with getBigInt64()

The first guide in the list: read 8 bytes as one exact 64-bit whole number.

getBigInt64() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful