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

How to return a number of bits used to display one color on a window screen in JavaScript?


Use the screen.colorDepth property in JavaScript to return a number of bits used to display a color on the window screen.

Example

You can try to run the following code to return the screen color depth in JavaScript.

<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("Screen width: " + screen.width);
         document.write("<br>Screen height: " + screen.height);
         document.write("<br>Color Depth: " + screen.colorDepth);
      </script>
   </body>
</html>