Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
console.log("0b111" ^ "0b001"); // 6 console.log(0b111 ^ 0b001); // 6
Though I can do this, is there any way to convert "0b111" to numeric literals 0b111 ? thanks.
parseInt("0b111".slice(2), 2)
const toBinaryFormat = (n) => `0b${n.toString(2)}`
toBinaryFormat(6) ==> "0b110"
numeric
6
number
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
parseInt("0b111".slice(2), 2)if you need to do it programmatically.const toBinaryFormat = (n) => `0b${n.toString(2)}`, and thentoBinaryFormat(6) ==> "0b110".numericliteral" is "6". that is how console displaysnumbers. \x0001 and 0b111 are syntax representations of anumber. what you are trying to ask for isn't possible and doesn't really make sense