Computer >> Computer tutorials >  >> Programming >> Javascript

How to convert Decimal to Binary in JavaScript?


To convert Decimal to Binary in JavaScript, you can try to run the following code.

Example

<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("Decimal to Binary<br>");
         document.write((-7 >>> 0).toString(2));
      </script>
   </body>
</html>