What is a Bit?

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).

Z-_21s6JSFaK8qL9HzYJvw.jpeg

What is a byte?

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

Assignment

What is the 11001010 converted to a decimals ?

Representing bits and bytes in JS

const x = 0;
console.log(x);
const x = 202
console.log(x);
const bytes = [202, 244, 1, 23]
console.log(bytes);

UInt8Array

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)