getOS
The getOS function returns the detected operating system in the browser environment.
Syntax
typescript
getOS(): string | undefined;Parameters
This function does not take any parameters.
Returns
| Type | Description |
|---|---|
string | undefined | The name of the detected operating system or undefined if it cannot be determined |
Examples
typescript
getOS();
// => "Windows", "macOS", "Linux", "Android", "iOS", "Unknown" or undefinedNotes
- Uses the
navigatorobject to identify the operating system. - Returns
undefinedif not in a browser environment. - May return "Unknown" if the system is not recognized.
