To get the color depth of the screen in JavaScript, use the screen.colorDepth
property.
Per the specification:
The colorDepth and pixelDepth attributes should return the number of bits allocated to colors for a pixel in the output device, excluding the alpha channel.
Read the docs. Read about color depth.