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

How to return pixel depth of the screen in JavaScript?


To return the pixel depth of the screen, use the screen.pixelDepth property in JavaScript.

Example

You can try to run the following code to get the pixel depth in JavaScript.

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