window object has a great API for working with screens(mobile devices, etc) and their related metadata -
For Mobile Devices and Full Screen browsers, you can use the following methods to toggle orientation locks:
Note that when you call the lock API on a web browser that is not full screen, it will raise a
DOMException similar to following:
DOMException: screen.orientation.lock() is not available on this device.
Acceptable orientation values can be found in the docs linked below