convert ascii to binary javascript code example
Example 1: binary to ascii javascript
const binaryAgent = str => str.replace(/\d+./g, char => String.fromCharCode(`0b${char}`));
Example 2: string to binary javascript
// string to binary
parseInt(num.toString(2));
// binary to string
parseInt(num.toString(2), 2);
Example 3: string to binary javascript
let num = 2020;
let x = +num.toString(2);
console.log(x);