A bit is the smallest unit of data in a computer and can have one of two values: 0 or 1.
Think of a bit like a light switch that can be either off (0) or on (1).
A byte is a group of 8
bits. It’s the standard unit of data used to represent a single character in memory. Since each bit can be either 0 or 1, a byte can have 2^8 (256) possible values, ranging from 0 to 255
What is the 11001010
converted to a decimals
?
const x = 0;
console.log(x);
const x = 202
console.log(x);
const bytes = [202, 244, 1, 23]
console.log(bytes);
A better way to represent an array of bytes is to use a UInt8Array
in JS
let bytes = new Uint8Array([0, 255, 127, 128]);
console.log(bytes)