ใช้ screen.colorDepth คุณสมบัติใน JavaScript เพื่อส่งคืนจำนวนบิตที่ใช้แสดงสีบนหน้าจอหน้าต่าง
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อคืนค่าความลึกของสีของหน้าจอใน 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>