How to return pixel depth of the screen in JavaScript?

HTMLJavascriptProgramming Scripts

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>
raja
Updated on 20-May-2020 11:02:04

Advertisements