How do I translate this Python to Javascript? BYTE_ARRAY = bytearray(b"x01")
Question:
I need to turn this line of Python to Javascript
BYTE_ARRAY = bytearray(b"x01")
Answers:
Uint8Array is like the bytearray Python function. It is used to create a byte array from hexadecimal.
const BYTE_ARRAY = new Uint8Array([0x01]);
Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
I need to turn this line of Python to Javascript
BYTE_ARRAY = bytearray(b"x01")
Uint8Array is like the bytearray Python function. It is used to create a byte array from hexadecimal.
const BYTE_ARRAY = new Uint8Array([0x01]);
Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array