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>