A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toHex below:

Uint8Array.prototype.toHex() - JavaScript | MDN

Uint8Array.prototype.toHex()

Limited availability

The toHex() method of Uint8Array instances returns a hex-encoded string based on the data in this Uint8Array object.

This method creates strings from a byte array. To convert individual numbers into hex, use the Number.prototype.toString() method with radix set to 16 instead.

Syntax Parameters

None.

Return value

A hex-encoded string representing the data in the Uint8Array.

Examples Encoding binary data

This example encodes data from a Uint8Array into a hex string.

const uint8Array = new Uint8Array([202, 254, 208, 13]);
console.log(uint8Array.toHex()); // "cafed00d"

const data = new Uint8Array([255, 0, 0, 0, 255, 0, 0, 0, 255]);
for (let i = 0; i < data.length; i += 3) {
  console.log(data.slice(i, i + 3).toHex());
}
// "ff0000"
// "00ff00"
// "00ff00"
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4