Get device PPI

Is there anyway that I can get the device PPI?

See if this works:
var pixelRatio = window.devicePixelRatio || 1;

Thanks for your reply.

I experiment on a device with 480 x 800 screen resolution with 240ppi. So, the actual device screen size is 2 x 3.334 inch, which is a 4 inch device.

However, the window.devicePixelRatio return the result of 1.5. How can I get the result of 240?