What are the use cases for JS involving the Photon2?

I saw that there is a particle-api-js, and it seems that the only reason one would use this library is to query/set system information in the photon2. Is this correct?
If not, please let me know how I am mistaken.

Separately, is there any documentation regarding the utilization of javascript with a photon2 via a web page? Would you normally utilize a webhook or are there other ways to communicate w/ DeviceOS from a standard JS-based web app?

Thank you!