By using typed arrays, you can store arrays of these types:

Type Value Range Size(bytes)
Int8Array -128 to 127 1
Uint8Array 0 to 255 1
Uint8ClampedArray 0 to 255 1
Int16Array -32768 to 32767 2
Uint16Array 0 to 65535 2
Int32Array -2147483648 to 2147483647 4
Uint32Array 0 to 4294967295 4
Float32Array -3.4E38 to 3.4E38 4
Float64Array -1.8E308 to 1.8E308 8
BigInt64Array -2^63 to 2^63 - 1 8
BigUint64Array 0 to 2^64 - 1 8

Demo in Stack Snippets & JSFiddle

var array = new Uint8Array(100);
array[42] = 10;
console.log(array[42]);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Answer from Kendall Frey on Stack Overflow
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Typed_arrays
JavaScript typed arrays - JavaScript | MDN
The DataView is a low-level interface that provides a getter/setter API to read and write arbitrary data to the buffer. This is useful when dealing with different types of data, for example. Typed array views are in the native byte-order (see Endianness) of your platform.
🌐
Reddit
reddit.com › r/javascripttips › how to convert string to byte array in javascript?
r/JavaScriptTips on Reddit: How to Convert String to Byte Array in JavaScript?
May 1, 2023 - A byte array is a contiguous block of memory that contains a sequence of bytes. Each byte in the array represents a numeric value between 0 and 255. Byte arrays are commonly used for low-level data manipulation and network communication.
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript store byte array
How to Store Byte Array in JavaScript | Delft Stack
February 2, 2024 - An array of bytes or byte array is known as the ArrayBuffer object in JavaScript.
🌐
Medium
medium.com › @julienetienne › different-types-of-arrays-in-javascript-and-when-to-use-them-77f7843b71de
Different Types of Arrays in JavaScript + When to Use Them | by Julien Etienne | Medium
February 8, 2024 - An ArrayBuffer is a “Byte Array”, which is an area of memory containing a group of contiguous (one after the other) bytes.
Find elsewhere
🌐
JavaScript.info
javascript.info › tutorial › binary data, files
ArrayBuffer, binary arrays
July 11, 2022 - Binary data in JavaScript is implemented in a non-standard way, compared to other languages. But when we sort things out, everything becomes fairly simple. The basic binary object is ArrayBuffer – a reference to a fixed-length contiguous memory area. ... This allocates a contiguous memory area of 16 bytes and pre-fills it with zeroes.
🌐
JavaScript in Plain English
javascript.plainenglish.io › javascript-data-encoding-and-decoding-techniques-buffers-byte-arrays-dataview-binary-219d55b535a2
JavaScript Data Encoding and Decoding Techniques: Buffers, Byte arrays, DataView, binary, hexadecimal, and decimals. | by Varun Kukade | JavaScript in Plain English
May 4, 2024 - Now we can accept the byte array and convert it to an appropriate format to read the data. In JavaScript, unlike some other programming languages such as Java, bytes are not explicitly defined as a primitive data type. Instead, JavaScript has a generic number data type.
🌐
Programmingwithswift
programmingwithswift.com › how-to-convert-byte-array-to-string-with-javascript
How to convert a byte array to String with JavaScript
December 28, 2020 - Converting an array of bytes to a string with JavaScript is very easy when we use the fromCharCode function, however, if you string have special characters you might want to look at a different solution.
🌐
GitHub
gist.github.com › lihnux › 2aa4a6f5a9170974f6aa
Javascript Convert String to Byte Array · GitHub
Array.from("1111222223333444445556", , (x) => x.charCodeAt(0)) ... function unpack(str) { var bytes = []; for(var i = 0; i < str.length; i++) { var char = str.charCodeAt(i); bytes.push(char >>> 8); bytes.push(char & 0xFF); } return bytes; } this is the correct way to extract the bytes a JavaScript string is made of
🌐
Designcise
designcise.com › web › tutorial › how-to-convert-a-javascript-byte-array-to-a-string
How to Convert a JavaScript Byte Array to a String? - Designcise
April 9, 2023 - In JavaScript, you can convert an array of bytes to string by using the TextDecoder API with UTF-8 encoding, for example, in the following way: function fromBinaryArray(bytes) { const decoder = new TextDecoder('utf-8'); return decoder.decode(bytes); ...
🌐
Substack
alexanderobregon.substack.com › alexander obregon's substack › reading binary data in javascript with typed arrays and arraybuffer
Reading Binary Data in JavaScript with Typed Arrays and ArrayBuffer
June 25, 2025 - It could be a file read from disk, a message sent over a WebSocket, or raw bytes from a Bluetooth device. Handling it the right way depends on tools built into the language. JavaScript gives you direct access to read and write binary through ArrayBuffer and typed array views like Uint8Array, which let you treat a block of raw bytes like a real data structure without extra libraries.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Response › bytes
Response: bytes() method - Web APIs - MDN Web Docs
September 4, 2026 - The bytes() method of the Response interface takes a Response stream and reads it to completion. It returns a promise that resolves with a Uint8Array.
🌐
Designcise
designcise.com › web › tutorial › how-to-convert-a-javascript-string-to-a-byte-array
How to Convert a JavaScript String to a Byte Array? - Designcise
April 9, 2023 - In JavaScript, you can convert a string to an array of bytes by using the TextEncoder API, for example, in the following way: function toBytesArray(str) { const encoder = new TextEncoder(); return encoder.encode(str); } console.log(toBytesA...
🌐
Bobby Hadz
bobbyhadz.com › blog › convert-string-to-byte-array-in-javascript
How to convert a String to a Byte Array in JavaScript | bobbyhadz
To convert a string to a byte array in JavaScript: Instantiate the TextEncoder() constructor to create a TextEncoder object. Call the encode() method on the object to convert the string to a byte array.
🌐
GitHub
github.com › frida › frida › issues › 293
How can I create byte array in js? · Issue #293 · frida/frida
June 26, 2017 - When I implement this function as js code, I don't know how to create a byte array. The function read of InputStream need byte array as first arg.
Author: frida