[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/setFromHex [Back]  [Original]

Uint8Array.prototype.setFromHex() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Uint8Array.prototype.setFromHex()

Baseline 2025

20259

setFromHex() Uint8Array Uint8Array 16

parseInt() radix 16

js
setFromHex(string)

string

Uint8Array 16

16

read

16 16

written

Uint8Array Uint8Array byteLength

SyntaxError

16

TypeError

16

16 Uint8Array

js
const uint8Array = new Uint8Array(8);
const result = uint8Array.setFromHex("cafed00d");
console.log(result); // { read: 8, written: 4 }
console.log(uint8Array); // Uint8Array(8) [202, 254, 208, 13, 0, 0, 0, 0]

js
const uint8Array = new Uint8Array(4);
const result = uint8Array.setFromHex("cafed00d-some random stuff");
console.log(result); // { read: 8, written: 4 }
console.log(uint8Array); // Uint8Array(4) [202, 254, 208, 13]

setFromHex() Uint8Array TypedArray.prototype.subarray()

js
const uint8Array = new Uint8Array(8);
//  2 
const result = uint8Array.subarray(2).setFromHex("cafed00d");
console.log(result); // { read: 8, written: 4 }
console.log(uint8Array);
// Uint8Array(8) [0, 0, 202, 254, 208, 13, 0, 0]

ECMAScript 2027 LanguageSpecification
# sec-uint8array.prototype.setfromhex


Web Proxy Viewer  |  New URL  |  Original Page