Rabib
Rabib

Reputation: 11

Can I use Binary or Octal in JavaScript?

I want to use Binary or Octal code like this hex code,

var ab=["\x61"];
document.write(ab[0]);

Upvotes: 1

Views: 147

Answers (1)

user8155415
user8155415

Reputation:

You are able to use octal and binary in JavaScript (at least since ES2015) by starting numbers with 0b and 0o. For example:

console.log("\x61"); // hex (a)
console.log(0b11); // binary (3)
console.log(0o11); // octal (9)

Upvotes: 1

Related Questions